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