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