#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  long long ans[t];
  for (long i = 0; i < t; i++) {
    long long x, y, a, b, sum = 0;
    cin >> x >> y >> a >> b;
    if (x == 0) {
      ans[i] = y * a;
    } else if (y == 0) {
      ans[i] = x * a;
    } else if (x == 0 && y == 0) {
      ans[i] = 0;
    } else {
      long long temp = abs(x - y);
      long long bigger = max(x, y);
      if (b < 2 * a) {
        sum += (bigger - temp) * b + temp * a;
        ans[i] = sum;
      } else {
        ans[i] = (x + y) * a;
      }
    }
  }
  for (long i = 0; i < t; i++) {
    cout << ans[i] << endl;
  }
}
