n=gets.to_i n.times{ l,r,a,b=gets.split(" ").map{|e| e.to_i} puts [l*a,r*a].max+b }