#include using namespace std; int main(){ int t;cin>>t; for(int i = 0; t > i; i++){ int a,b,c,d;cin>>a>>b>>c>>d; cout << max(a*c,b*c)+d << endl; } }