#include <bits/stdc++.h>
using namespace std;
long long basic() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  return 0;
}
bool comp(long long a, long long b) { return a > b; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long x, y, a, b;
    cin >> x >> y >> a >> b;
    long long small, big, sum = 0;
    if (x < y) {
      small = x;
      big = y;
    } else {
      small = y;
      big = x;
    }
    if (a <= (b / 2)) {
      sum = a * (x + y);
    } else {
      sum = (small * b) + ((big - small) * a);
    }
    cout << sum << endl;
  }
  return 0;
}
