#include <bits/stdc++.h>
using namespace std;
long long t, x, y, a, b, s = 0, v, c = 0;
int main() {
  cin >> t;
  while (t--) {
    cin >> x >> y >> a >> b;
    if (x != y) {
      v = x > y ? x : y;
      if (v == x) {
        c = x - y;
        s += (c * a);
        x -= c;
      } else {
        c = y - x;
        s += (c * a);
        y -= c;
      }
    }
    if (x == y) {
      v = x + y;
      if (v * a > x * b)
        s += (x * b);
      else
        s += (v * a);
    }
    cout << s << "\n";
    s = 0;
    v = 0;
  }
}
