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