#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int x, y, a, b;
    cin >> x >> y;
    cin >> a >> b;
    long long int ans = 0;
    if (b <= 2 * a) {
      ans += b * min(x, y);
      long long temp = min(x, y);
      x -= temp;
      y -= temp;
      ans += a * max(x, y);
    } else {
      ans += a * (x + y);
    }
    cout << ans << endl;
  }
}
