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