#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
const unsigned int MODULO = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t > 0) {
    long long x, y, a, b;
    cin >> x >> y;
    cin >> a >> b;
    long long c;
    c = abs(x - y) * a + min(x, y) * b;
    cout << min(c, (x + y) * a) << endl;
    --t;
  }
  return 0;
}
