#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma comment(linker, "/stack:200000000")
using namespace std;
const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;
const long long inf = 1e15 + 4;
long long x, y, a, b;
void solve() {
  cin >> x >> y >> a >> b;
  if (x > y) swap(x, y);
  if (a * 2 < b) {
    cout << x * a + y * a << '\n';
    return;
  } else {
    cout << x * b + (y - x) * a << '\n';
    return;
  }
}
int main() {
  int tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
