#include <bits/stdc++.h>
using namespace std;
long long t, a, b, x, y;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  for (int test = 1; test <= t; test++) {
    cin >> x >> y >> a >> b;
    cout << (long long)min((x + y) * a,
                           min(x, y) * b + (max(x, y) - min(x, y)) * a)
         << '\n';
  }
}
