t = gets.to_i
ans = []
t.times do
  n = gets.to_i
  k = []
  l = []
  r = []
  n.times do |i|
    k[i],l[i],r[i] = gets.chomp.split(" ").map(&:to_i)
  end
  matrix = Array.new(n,0)
  n.times do |i|
    matrix = matrix[0..(k[i]-1)].map{|x| x + l[i]} + matrix[k[i]..-1].map{|x| x+r[i]}
  end
  ans.push(matrix.max)
end
ans.each do |x|
  puts x
end