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