#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long x, y, a, b;
    cin >> x >> y >> a >> b;
    long long xx = min(x, y), yy = max(x, y);
    long long tog = xx, diff = yy - xx;
    long long ans = min(tog * b + diff * a, (yy + xx) * a);
    cout << ans << '\n';
  }
  return 0;
}
