#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long int s = 0, a, b, c, d, x, y;
    cin >> x >> y >> a >> b;
    if (a * 2 <= b)
      s = (x + y) * a;
    else {
      if (x >= y) {
        c = x - y;
        d = y;
      } else {
        c = y - x;
        d = x;
      }
      s = (c * a) + (d * b);
    }
    cout << s << endl;
  }
}
