#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int64_t x, y;
    cin >> x >> y;
    int64_t a, b;
    cin >> a >> b;
    int64_t sub = abs(x - y);
    int64_t ans = 0;
    ans += sub * a;
    if ((2 * a) > b) {
      ans += b * ((x + y - sub) / 2);
    } else {
      ans += a * (x + y - sub);
    }
    cout << ans << endl;
  }
  return 0;
}
