#include <bits/stdc++.h>
using namespace std;
long long i, j, k, z, a[100000], d[2000000], lll, rrr,
    c[200000] = {0}, x, y, xx, yy, t, p, q, n, ll, rr, r, cap, cap2, capp,
    capp2;
char ii, jj, l[200000], bb[200000], tt[1000][10000];
int main() {
  cin >> t;
  for (j = 0; j < t; j++) {
    cin >> x >> y >> p >> q;
    if (x > y) {
      if (q >= 2 * p) {
        n = (x + y) * p;
      } else {
        x = x - y;
        n = y * q + x * p;
      }
    } else {
      if (q >= 2 * p) {
        n = (x + y) * p;
      } else {
        y = y - x;
        n = x * q + y * p;
      }
    }
    cout << n << "\n";
  }
}
