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