#include using namespace std; typedef long long ll; typedef unsigned long long ull; int main(void) { ios_base::sync_with_stdio(false); int tests; cin >> tests; for (int i = 0; i < tests; i++) { int myH, liftH, mySpeed, liftSpeed; cin >> myH >> liftH >> mySpeed >> liftSpeed; cout << min(myH * mySpeed, abs(myH - liftH) * liftSpeed + myH * liftSpeed) << endl; } return 0; }