#include <bits/stdc++.h>
using namespace std;
long long int f() {
  long long int x, y, a, b;
  cin >> x >> y;
  cin >> a >> b;
  if (x == 0 && y == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long int cnt = x + y;
  cnt = (cnt * a);
  long long int mn = min(x, y);
  long long int sum = mn * b + (((x - mn) + (y - mn)) * a);
  cout << min(sum, cnt) << endl;
  return 0;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    f();
  }
  return 0;
}
