#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long x, y, a, b;
    cin >> x >> y >> a >> b;
    if (2 * a <= b) {
      cout << (x + y) * a << '\n';
      continue;
    }
    cout << min(x, y) * b + abs(x - y) * a << '\n';
  }
}
