#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const char nwl = '\n';
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int x, y, a, b;
    long long s = 0;
    cin >> x >> y >> a >> b;
    if (!x && !y) {
      s = 0;
    } else if (2 * a <= b) {
      s = (long long)(x + y) * a;
    } else {
      if (x > y) swap(x, y);
      s = (long long)x * b;
      s += (long long)(y - x) * a;
    }
    cout << s << nwl;
  }
  return 0;
}
