#include using namespace std; #define st first #define nd second #define pb push_back using ll = long long; using db = double; using ldb = long double; using pii = pair; using pll = pair; void solve(){ ll yp, lp, ys, ls; cin >> yp >> lp >> ys >> ls; if(ys <= ls){ cout << ys * yp << "\n"; return; } ll best = ys * yp; if(yp <= lp){ best = min(best, ls * lp); } else{ // winda plycej ll total = yp + (yp - lp) * 2; best = min(best, total * ls); best = min(best, ys * (yp - lp) + lp * ls); } cout << best << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) solve(); return 0; }