#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int y, a, b, min;
    long long int n, k, i, m, j = 1, flag = 0, c1 = 0, c2 = 0, s2 = 0, sum = 0,
                              diff, ans, x, max = 0, lind = 1;
    float avg;
    cin >> x >> y;
    cin >> a >> b;
    if (x <= y) {
      min = x;
      diff = y - x;
    } else {
      min = y;
      diff = x - y;
    }
    ans = min * b + (diff)*a;
    if (ans < a * (x + y))
      cout << ans << "\n";
    else
      cout << a * (x + y) << "\n";
  }
}
