class Route
#    rt: List, rt= [[x1, x2, y1], [x1, x3, y2],...]     x1->x2 cost y1
  def initialize(nMachi, rt)
    @nMachi=nMachi
    @rt = rt.dup
  end

  def solve(start, dest)
    goal =dest
    aux(start, [], 0, goal)
  end

  def aux(start, visit, sum, goal) # search route from start
    if start== goal then
      return sum
    else
      rt1=@rt.select{|from,to,cost| from==start and !visit.index(to)}
      rst= rt1.map{|from,to,cost|
        aux(to, visit+[start], sum+cost, goal)
      }
      return rst.select{|x| x}.min
    end
  end

end

def main()
  if true then
    fh=STDIN
  else
    fh=open("in1_0117.txt", "r")
  end

  nMachi=fh.gets.chomp.to_i
  nKaido=fh.gets.chomp.to_i

  rt = []
  0.upto(nKaido-1){|i|
    x1,x2,y1,y2=fh.gets.chomp.split(/,/).map{|x|x.to_i}
    rt.push [x1, x2, y1]
    rt.push [x2, x1, y2]
  }
  start,dest,moto,hashira=fh.gets.chomp.split(/,/).map{|x|x.to_i}

  r=Route.new(nMachi,rt)
  go=r.solve(start,dest)
  ret=r.solve(dest,start)
  reward = moto - go - ret - hashira
  puts reward
end

if __FILE__ == $0 then
  main
end