#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MAXM = 1000005;
const int MOD = 1000000007;
const int MAMOD = 998244353;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EPS = 1e-8;
int main() {
  ios::sync_with_stdio(0);
  int T;
  long long x, y, a, b;
  cin >> T;
  while (T--) {
    long long ans = 0;
    cin >> x >> y;
    cin >> a >> b;
    if (b >= 2 * a)
      ans = (x + y) * a;
    else
      ans = min(x, y) * b + abs(y - x) * a;
    cout << ans << "\n";
  }
  return 0;
}
