using System; public class Hello { static void Main() { var t = int.Parse(Console.ReadLine().Trim()); while (t-- > 0) { string[] line = Console.ReadLine().Trim().Split(' '); var L = int.Parse(line[0]); var r = int.Parse(line[1]); var a = int.Parse(line[2]); var b = int.Parse(line[3]); Console.WriteLine(a >= 0 ? a * r + b : a * L + b); } } }