#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long x, y, a, b;
  cin >> x >> y >> a >> b;
  if (2 * a < b) {
    cout << a * (x + y) << "\n";
    ;
    return;
  } else {
    cout << b * min(x, y) + a * abs(x - y) << "\n";
    ;
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
