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