#include <bits/stdc++.h>
using namespace std;
vector<int> v, v1, v2, d, a;
set<int> st;
const int N = 1e6;
int n, m, cnt = 0;
map<int, int> used;
int main() {
  ios_base::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    long long x, y, a, b, cnt, ans;
    cin >> x >> y;
    cin >> a >> b;
    if (y > x) swap(x, y);
    cnt = (x + y) * a;
    ans = (y * b) + (x - y) * a;
    cout << min(cnt, ans) << "\n";
  }
}
