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