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