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