n=gets.to_i
m=gets.to_i

array=Array.new(n)
  n.times{|t|
  array[t]=Array.new(n, 100000000)
}
m.times{
  a,b,c,d=gets.split(",").map{|e|e.to_i}
  array[a-1][b-1]=c
  array[b-1][a-1]=d
}

#k,i,j=0,0,0
for k in 0..n-1 do
  for i in 0..n-1 do
    for j in 0..n-1 do 
      array[i][j]=array[i][k]+array[k][j] if array[i][j]>array[i][k]+array[k][j]
      j+=1
    end
    i+=1
  end
  k+=1
end
x1,x2,y1,y2=gets.split(",").map{|e|e.to_i}

#array.each{|e|p e}

p y1-y2-array[x1-1][x2-1]-array[x2-1][x1-1]