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