#include <bits/stdc++.h>
using namespace std;
long long caseno, n, x, y, a, b;
void ResetAll() {}
void Input() {
  scanf("%lld%lld", &x, &y);
  scanf("%lld%lld", &a, &b);
}
void Calculation() {
  long long res = abs(x - y) * a;
  long long baki = min(x, y);
  if (baki * b < 2 * baki * a) {
    res += baki * b;
  } else {
    res += 2 * baki * a;
  }
  printf("%lld\n", res);
}
void Solve() {
  Input();
  Calculation();
  ResetAll();
}
int main() {
  int q;
  scanf("%d", &q);
  caseno = 0;
  while (q--) {
    caseno++;
    Solve();
  }
  return 0;
}
