#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long long int P = 1000000007;
const double eps = 1e-6;
void solve() {
  long long int x, y, a, b;
  cin >> x >> y >> a >> b;
  long long int ans = 0;
  ans += (abs(x - y) * a);
  ans += ((min(x, y)) * min(2 * a, b));
  cout << ans, cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  for (long long int test = 1; test <= t; test++) {
    solve();
  }
  cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
