#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; void solve() { int L, R, A, B; cin >> L >> R >> A >> B; cout << max(A*L+B, A*R+B) << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while(t--) { solve(); } }