#include <bits/stdc++.h>
using namespace std;
int main() {
  long long test;
  scanf("%lld", &test);
  long long loop;
  for (loop = 1; loop <= test; loop++) {
    long long x, y, a, b;
    scanf("%lld", &x);
    scanf("%lld", &y);
    scanf("%lld", &a);
    scanf("%lld", &b);
    long long cost = 0;
    if (x == 0 && y == 0)
      printf("%lld\n", cost);
    else {
      long long diff = std::max(x, y) - std::min(x, y);
      cost += (diff * a);
      if (b <= 2 * a)
        cost += b * std::min(x, y);
      else
        cost += 2 * a * std::min(x, y);
      printf("%lld\n", cost);
    }
  }
  return 0;
}
