#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;
    long long ans = (b < 2 * a) ? min(x, y) * b : min(x, y) * 2 * a;
    ans += (x + y - 2 * min(x, y)) * a;
    cout << ans << endl;
  }
  return 0;
}
