#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(int i=0;i> T; REP(tc,T){ int L,R,A,B; cin >> L >> R >> A >> B; cout << max(A*L+B,A*R+B) << endl; } return 0; }