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