#include <bits/stdc++.h>
using namespace std;
const long long dx[4] = {-1, 0, 0, 1};
const long long dy[4] = {0, -1, 1, 0};
const long long INF = 1e18;
const long long mod = 1000000007;
long long a, b, n, m, x, k, c, y, z, i, ans, sum, maxx, v[2555][2555], d;
long long na, ma, nb, mb;
long long br[1456789], ar[1456789], mn[1456789], mx[1456789], used[1456789],
    g[55][55];
char h[1234][1234], p[55][55];
string s, t, ress;
vector<pair<long long, long long> > ss, mm, vv;
vector<long long> vec, as;
map<long long, long long> mmap;
bool ok[1456789], oka;
char ch;
void dii() {
  cin >> a >> b >> x >> y;
  if (x * 2 < y) {
    cout << (a + b) * x;
    cout << endl;
    return;
  }
  if (a > b) {
    cout << b * y + (a - b) * x;
    cout << endl;
    return;
  } else {
    cout << a * y + (b - a) * x;
    cout << endl;
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  cin >> q;
  while (q--) dii();
  return 0;
}
