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