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