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