#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 3;
const int INF = 1e9;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int ntest;
  cin >> ntest;
  while (ntest--) {
    long long x, y, a, b;
    cin >> x >> y >> a >> b;
    long long ans = a * (abs(x) + abs(y));
    mmin(ans, b * abs(x) + a * abs(y - x));
    mmin(ans, b * abs(y) + a * abs(x - y));
    cout << ans << '\n';
  }
  return 0;
}
