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