#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int x, y, a, b;
  cin >> x >> y >> a >> b;
  long long int ans1 = (x + y) * a;
  long long int ans2 = (max(x, y) - min(x, y)) * a + min(x, y) * b;
  cout << min(ans1, ans2) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  for (long long int tno = 1; tno < t + 1; tno++) {
    solve();
  }
  return 0;
}
