#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long base = 998244353;
const long long oo = 1e6 + 10;
const long long gh = 1e3 + 3;
const long long inf = 1e15 + 5;
long long n, m, k, q;
long long a[oo];
long long b[oo];
long long sum[oo];
string s;
char c[oo];
void input() {
  long long x, y, a, b;
  cin >> x >> y >> a >> b;
  if (b <= 2 * a)
    cout << min(x, y) * b + (x + y - 2 * min(x, y)) * a << endl;
  else
    cout << (x + y) * a << endl;
}
void cre() {}
void solve() { cre(); }
void ouput() {}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (ifstream("test.txt")) {
    freopen("test.txt", "r", stdin);
  } else if (ifstream(""
                      ".inp")) {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  long long t = 1;
  cin >> t;
  while (t--) {
    input();
    solve();
    ouput();
  }
}
