#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int x, y;
    cin >> x >> y;
    long long int a, b;
    cin >> a >> b;
    long long int ans1 = b * min(x, y) + a * abs(x - y);
    long long int ans2 = a * (x + y);
    if (ans1 < ans2)
      cout << ans1 << "\n";
    else {
      cout << ans2 << "\n";
    }
  }
  return 0;
}
