#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long x, y, a, b, ans = 0;
    cin >> x >> y;
    cin >> a >> b;
    ans += a * abs(y - x);
    x = min(x, y);
    if (2 * a < b) {
      ans += x * 2 * a;
    } else {
      ans += b * x;
    }
    cout << ans << "\n";
  }
}
