#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 pivot = min(x, y);
    long long int Max = max(x, y);
    if (b > 2 * a) {
      cout << a * (x + y) << '\n';
    } else {
      cout << b * (pivot) + (Max - pivot) * a << '\n';
    }
  }
  return 0;
}
