#include using namespace std; int main() { int t;cin>>t; while(t--){ int l,r,a,b;cin>>l>>r>>a>>b; cout << (a*(a>=0?r:l)+b)<