n, m = gets.split.map(&:to_i)
a = []
b = []
b << 0; b << n-1
h = {}
l = gets.split.map(&:to_i)
l.each_cons(2){|s, t| a << [s-1, t-1]; b << s-1; b << t-1 }
b.uniq!; b.sort!
bs = b.size
b.each_with_index{|e, i| h[e]=i }
trip = [0]*(bs-1)
a.each do |s, t|
  s,t = t,s if s > t
  for i in (h[s]...h[t])
    trip[i] += 1
  end
end
sum = 0
cnt = 0
(n-1).times do |i|
  p, q, r = gets.split.map(&:to_i)
  cnt += 1 if b[cnt+1] <= i
  (p-q)*trip[cnt] < r ? (sum += p*trip[cnt]) : (sum += q*trip[cnt]+r)
end
p sum