//"তুই কে - রাজাকার আমি কে - রাজাকার কে বলেছে কে বলেছে - স্বৈরাচার স্বৈরাচার " [Our PM said we are "রাজাকার" ] ~ from protester_Kaminaaa 16.7.2024
/*
⣿⣿⣿⣿⡿⠟⠛⠋⠉⠉⠉⠉⠉⠛⠛⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⠟⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠈⠙⠾⣿⣾⣿⣾⣿⣾⣿⣾⣿
⠋⡁⠀⠀⠀⠀⠀⢀⠔⠁⠀⠀⢀⠠⠐⠈⠁⠀⠀⠁⠀⠈⠻⢾⣿⣾⣿⣾⣟⣿
⠊⠀⠀⠀⠀⢀⠔⠃⠀⠀⠠⠈⠁⠀⠀⠀⠀⠀⠀⠆⠀⠀⠄⠀⠙⣾⣷⣿⢿⣿
⠀⠀⠀⠀⡠⠉⠀⠀⠀⠀⠠⢰⢀⠀⠀⠀⠀⠀⠀⢰⠀⠀⠈⡀⠀⠈⢿⣟⣿⣿
⠀⠀⢀⡜⣐⠃⠀⠀⠀⣠⠁⡄⠰⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠰⠀⠀⠈⢿⣿⣿
⠀⢠⠆⢠⡃⠀⠀⠀⣔⠆⡘⡇⢘⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿
⢀⡆⠀⡼⢣⠀⢀⠌⢸⢠⠇⡇⢘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿
⣼⣃⠀⠁⢸⢀⠎⠀⢸⠎⠀⢸⢸⡄⠀⠀⠀⠀⠀⠂⢀⠀⠀⠀⠀⠀⠀⠀⠀⣿
⠃⡏⠟⣷⣤⠁⠀⠀⠸⠀⠀⡾⢀⢇⠀⠀⠀⠀⠀⠄⠸⠀⠀⠀⠀⠄⠀⠀⠀⣿
⠀⠀⣀⣿⣿⣿⢦⠀⠀⠀⠀⡧⠋⠘⡄⠀⠀⠀⠀⡇⢸⠀⠀⠠⡘⠀⠀⠀⢠⣿
⠈⠀⢿⢗⡻⠃⠀⠀⠀⠀⠀⠀⠀⠀⠱⡀⠀⠀⢰⠁⡇⠀⠀⢨⠃⡄⢀⠀⣸⣿
⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣱⠀⠀⡎⠸⠁⠀⢀⠞⡸⠀⡜⢠⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣺⣿⣧⢰⣧⡁⡄⠀⡞⠰⠁⡸⣠⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⡿⠏⣿⠟⢁⠾⢛⣧⢼⠁⠀⠀⢰⣿⡿⣷⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠡⠄⠀⡠⣚⡷⠊⠀⠀⠀⣿⡿⣿⡿⣿
⡀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠁⢸⠁⠀⠀⠀⢰⣿⣿⡿⣿⣿
⠱⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠊⠀⠀⠀⡞⠀⠀⠀⠀⢸⣿⣷⣿⣿⣿ /*"kawaiiiiiii!!!!!!!!!!!"*\
⠀⠙⢦⣀⠀⠀⠀⠀⠀⢀⣀⣠⠖⠁⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⣸⣿⣾⡿⣷⣿
⠀⠀⠀⠀⠉⠉⣩⡞⠉⠁⠀⢸⡄⠀⠀⠀⠀⠀⢰⠇⠀⠀⠀⠀⣿⣿⣷⣿⣿⣿
⡆⠀⠀⣀⡠⠞⠁⣧⢤⣀⣀⣀⡇⠀⠀⠀⠀⠀⣸⠀⠀⠀⠀⠀⣿⣷⣿⣷⣿⣿
⣿⣷⠊⠁⠀⠀⡰⠁⠀⠀⠀⠀⣹⠶⢦⡀⠀⠀⡇⠀⠀⠀⠀⠀⢸⣿⣷⣿⣷⣿
⣿⢿⠀⠀⠀⡔⠁⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⡄⡇⠀⠀⠀⠀⠀⠈⣿⣾⣷⣿⣿
⠋⠈⠀⢀⠜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠈⣧⠀⠀⠀⠀⠀⠀⠻⣿⣽⣾⣿
⢀⡄⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠁⠀⠀⠀⣸⠀⠀⠀⠀⠀⠀⠀⣿⣿⣻⣿
⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⢰⠀⠐⠀⠀⠀⠀⣀⡿⠀⠀⠀⠀⠀⠀⠀⢹⣿⣻⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠀⠀⠀⠀⠀⢀⣃⡇⠀⠲⡀⠀⠀⠀⠀⠈⣿⡿⣿
⣀⠤⠤⠤⡀⠀⠀⠀⠀⡴⠃⠀⠀⠀⠀⠀⢬⠞⡇⠀⠀⠇⠀⠀⠀⠀⠀⣿⣿⣿
⡁⢀⠀⠀⡇⠀⠀⠀⡼⠁⠀⠀⠀⠀⠀⣸⠁⠀⠇⠀⠀⡇⠀⠀⠀⠀⠀⣿⣿⣿
⠔⠃⠀⠀⡇⠀⠀⡼⠁⠀⠀⠀⠀⠀⢀⡇⠀⠀⡃⠀⠀⠙⢄⠀⠀⠀⠀⣿⣷⣿
⠒⠊⠀⠀⢸⠀⣸⠃⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⢅⠀⠀⡂⠸⡄⠀⠀⠀⣿⣟⣿
⠓⠀⠉⠀⢸⣰⠃⠀⠀⠀⠀⠀⠀⡜⡆⠀⠀⠀⢸⠀⠀⡇⢀⠇⠀⠀⠀⣿⣿⣿
⠉⠁⠀⢠⠞⠀⠀⠀⠀⠀⠀⠀⣰⠁⡇⠀⠀⠀⡇⠀⠀⡇⢸⠀⠀⠀⠀⣿⣷⣿
⡀⠀⢀⢿⣥⡤⠤⠤⠤⣀⣀⢠⠇⠀⢸⠀⠀⢰⠁⠀⢨⠀⢸⠀⠀⠀ ⣿⣟⣿
*/
/*
/* writer : chainsa_min *\
time : 20:49
date : 5/9/2024
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// hellow it's me .. "me ?" you beloved bastard_chao_min :] and tnx to you for reading my code
#define ll long long
#define maxi 1e17
#define MOD 1e9 + 7
#define pie 3.14159265358979323846264338327
#define nissan for (i=0; i<n; i++)
#define skyline for(i=1;i<=n;i++)
#define AE86 for(i=0;i<n-1;i++)
#define Rx7 for(i=1;i<n;i++) //Mazda RX-7 Savana.
#define in cin>>n
#define on string s
#define up cin >> s
#define be(v) v.begin(), v.end()//v(n)
#define sbe(v); sort( v.begin(), v.end())//v(n)
/* ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´HELLO´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´ */
/* _________________________It's Me DEADPOOL!! (>‿◠)✌´ _________________________*/
#define mii map<int,int>v;
#define mcl map<char,ll>
#define msl map<string,ll>
#define emb emplace_back
#define mpi make_pair
#define seti pair<ll,ll>
#define pub push_back
#define vei vector<int>
#define ves vector<string>
#define vec vector<char>
#define vpl vector<seti>
#define deq deque<ll>
#define maxv(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define minv(a,b) (a)=min((a),(b));
#define debv(v) for(auto it : v) cout << it << " ";
#define deb(x) cout << #x << " = " << x << " ";
#define vel vector<ll>
#define bv2 bitset<14> b(v[i])//2^n = x n = 16 32 64 ......
#define b32 bitset<32>
#define chifuyu iota(v.begin(), v.end(), 1)
#define mustano accumulate(v.begin(), v.end(), 0LL)
#define sei set<ll>
#define mappa map<ll,ll>
#define sj7 ara[n]
#define supra ara[i]
#define matsuno nissan { cin >> ara[i] ;}
#define dazai nissan {cin >> v[i];}
#define dbg(a) cerr << __LINE__ << ": " << #a << " = " << a << '\n'
#define optimus_prime vector<int>::iterator it
#define flash cout << *it << endlll // if(*it==n) *it = x (x replacing n && sit on this place)
#define nsx_r cin >> ara[i]
#define evo n = s.size();
#define ash ll j , i, n , m ,sums , a , b, c,d, val_stor , val_stor1 , val_stro2 , val_stor3 , count_kor = 0 , k , sum = 0 , x , y, z , count_kor_1 = 0
#define gtr '\n'
// double sub_x = pow(x1 - x2, 2);
#define chainsaw cout << "YES" <<gtr
#define vapub nissan { cin >> x; v.pub(x);}
#define man cout << "NO"<<gtr
#define se ' '
#define se2 " "
#define tithi s.begin(), s.end() // dont think she my gf -;( she is mine own little sister -:}
#define mitsuha_wifu ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define kyouka_chan freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define folafol(x) cout << x << gtr ;
#define folafol_1(x,y) ; cout << x << se2 << y ;
#define she(a,b,i) for (ll i = a; i < b; i++)
#define her(a,b,i) for (ll i = a; i <=b; i++)
#define bjt(a,b,i) for(ll i = a ; i>=b ; i-- )
#define ss second
#define println(x) cout << x << gtr ;
#define folafol_2(x,y) cout << x << " " << y ; cout << gtr ;
#define sayonara return 0
#define lancer_ ll guts ; cin >> guts ; while(guts--)
#define hell_ #ifndef ONLINE_JUDGE
#define _sign kyouka_chan ; #endif
//---------------------------start---------------------------------
// const int MOD = 1e9 + 7;
// double average = static_cast<double>(sum) / n;
// sort(a(v), greater<ll>()); means reverse(a(v)) ;
bool comp_are (seti a , seti b) {
if(a.first==b.first){
return a.second<b.second ;
}
else
return a.first > b.first;
}
bool comps (seti a , seti b) {
if((a.first == b.first))
return (a.second > b.second);
else
return (a.first<b.first) ;
}
// for 2 pointer l = 0 r= n-1 \
ll tringle(ll a , ll b, ll c ) {
if((a+b)>c && (b+c)>a && (c+a)>b)
{
return 1 ;
}
else return 0 ;
}
ll segment (ll a , ll b, ll c ) {
if((a+b)==c || (b+c)==a || (c+a)==b)
{
return 1 ;
}
else return 0 ;
}
#define outs(x) for(auto a:x) cout << a << " "; cout << endl
ll N = 500;
int main (){
mitsuha_wifu ;
//bool flag = 0 ; // true
#ifndef ONLINE_JUDGE
kyouka_chan ;
#endif
lancer_
{
ash , zero_cnt = 0 , one_cnt = 0 , e , f , val , val1 ;
bool flag = 0 ;
cin >> n >> d;
cin >> a >> b ;
if (n <= d) {
sum = n * a;
}
else {
sum = (d * a) + ((n - d) * b);
}
cout << sum << endl;
}
return 0 ;
}