#define _USE_MATH_DEFINES #include using namespace std; using ul = unsigned long long; using ll = long long; using ld = long double; using pll = pair; #define in(v,c) ((c).find(v) != (c).end()) #define F(i,n) for(ll i = 0; i < (ll)(n); i++) #define Fun(i,n) for(ul i = 0; i < (n); i++) #ifdef GPD templatevoid lerr(F&&f){cerr<(f)<void lerr(F&&f,R&&...r){cerr<(f)<<' ';lerr(forward(r)...);} #else #define lerr(...) #endif ll yp, lp, ys, ls; int main() { ll T; cin >> T; while(T--){ cin >> yp >> lp >> ys >> ls; ll time_vytah = (abs(yp - lp) + yp) * ls; ll time_you = yp*ys; ll time_to_lift = abs(yp-lp)*ys + lp*ls; ll mina = min(time_you, time_to_lift); cout << min(mina, time_vytah) << endl; } return 0; }