#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n, m;
  long long x, y, a, b, k;
  cin >> k;
  while (k--) {
    cin >> x >> y >> a >> b;
    long long ans = 0;
    if (a * 2 <= b) {
      ans = (x + y) * a;
    } else {
      long long u = x + y;
      ans = b * (min(x, y)) + a * (u - 2 * min(x, y));
    }
    printf("%lld\n", ans);
  }
}
