#include #include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n, m) for (int i = (int)(n); i > (int)(m); i--) using namespace atcoder; using ll = long long; const ll MOD1 = 1000000007LL; const ll MOD2 = 998244353LL; using namespace std; const vector> dpos4 = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; // const vector> dpos8 = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; template bool chmax(T &a, const T &b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } int main() { int T; cin >> T; rep(i, T){ ll L, R, A, B; cin >> L >> R >> A >> B; cout << max(L * A + B, R * A + B) << endl; } return 0; }