#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const long long mod = 998244353ll;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long x, y, a, b;
    scanf("%lld %lld %lld %lld", &x, &y, &a, &b);
    if (x > y) swap(x, y);
    long long ans = 0;
    if (b - a - a >= 0)
      ans = (x + y) * a;
    else
      ans = x * b + (y - x) * a;
    printf("%lld\n", ans);
  }
  return 0;
}
