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