#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    unsigned long long x, y;
    unsigned long long a, b;
    cin >> x >> y >> a >> b;
    cout << min(min(x, y) * b + llabs(y - x) * a, (x + y) * a) << endl;
  }
  return 0;
}
