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