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