#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 10;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  long long x, y;
  long long a, b;
  while (t--) {
    cin >> x >> y;
    cin >> a >> b;
    long long diff = abs(x - y);
    long long ans = a * diff;
    long long phakoff = min(x, y);
    if (2 * a < b) {
      ans += phakoff * a * 2;
    } else {
      ans += phakoff * b;
    }
    cout << ans << endl;
  }
  return 0;
}
