题目链接:点击打开链接
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
inline void rd(int &n){
n = 0;
char c = getchar();
while(c < '0' || c > '9') c = getchar();
while(c >= '0' && c <= '9') n *= 10, n += (c - '0'),c = getchar();
}
ll n;
ll solve(ll x){
ll maxx = x;
while(x!=1){
// cout<<x<<" ";
if(x&1)
x = x*3+1;
else x>>=1;
maxx = max(maxx, x);
}
return maxx;
}
int main(){
int T, Cas; scanf("%d",&T);
while(T--){
scanf("%d %lld", &Cas, &n);
printf("%d %lld\n", Cas, solve(n));
}
return 0;
}
/*
*/