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