T = gets.to_i

T.times do
  l, r, a, b = gets.split.map(&:to_i)

  puts [a * l + b, a * r + b].max
end