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