#include <bits/stdc++.h>
using namespace std;
const string sep = " ";
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    long long x, y;
    long long a, b;
    cin >> x >> y >> a >> b;
    if (b >= 2 * a) {
      cout << ((x) + (y)) * a << endl;
      continue;
    } else {
      cout << (min(x, y) * b + (max(x, y) - min(x, y)) * a) << endl;
    }
  }
}
