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