#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
double t,n,m,k,l,r,op,x,y,H;
int f[N];
bool flag;
void solve(){
cin>>t;
while(cin>>H>>n){
x = 0;
do{
x+=H;
if(--n==0)break;
H/=2;
x+=H;
}while(H);
cout<<x<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}