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