#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int tc;
  cin >> tc;
  while (tc--) {
    long long int x, y;
    cin >> x >> y;
    long long int a, b;
    cin >> a >> b;
    long long int maxn = max(x, y);
    long long int minn = min(x, y);
    if (x == 0 && y == 0) {
      cout << 0 << endl;
      continue;
    }
    long long int sum = minn * b + (maxn - minn) * a;
    long long int sum2 = (x + y) * a;
    cout << min(sum, sum2) << endl;
  }
  return 0;
}
