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