#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int tt;
long long x, y, a, b;
int main() {
  cin >> tt;
  while (tt--) {
    cin >> x >> y >> a >> b;
    x = abs(x);
    y = abs(y);
    if (x > y) swap(x, y);
    long long ans = min(a * (x + y), b * x + (y - x) * a);
    cout << ans << endl;
  }
  return 0;
}
