#include using namespace std; int main(){ int T; cin >> T; while(T--){ int L, R, A, B; cin >> L >> R >> A >> B; cout << max(A * L + B, A * R + B) << endl; } }