#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int x, y;
    cin >> x >> y;
    int a, b;
    cin >> a >> b;
    int p = 0;
    if (x > y) {
      p = x - y;
    } else if (y > x) {
      p = y - x;
    }
    int ans = 0;
    if (x == 0 && y == 0) {
      ans = 0;
    } else if (x == y) {
      ans = min(min(x, y) * b,
                min(2 * (min(x, y) - 1) * a + b, 2 * (min(x, y)) * a));
    } else {
      ans = p * a + min(min(x, y) * b,
                        min(2 * (min(x, y) - 1) * a + b, 2 * (min(x, y)) * a));
    }
    long long int m1, m2, m3, ele = 0;
    if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
      m1 = min(llabs(x), llabs(y)) * b +
           llabs(llabs(x) + llabs(y) - 2 * min(llabs(x), llabs(y))) * a;
      ele++;
      ele--;
      m2 = llabs(x) * a + llabs(y) * a;
      cout << min(m1, m2) << endl;
    } else {
      m1 = llabs(x) * a + llabs(y) * a;
      cout << m1 << endl;
    }
  }
}
