Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 78 ms):
#include <bits/stdc++.h>
using namespace std;
#define inp(v,n) vector <int> v(n) ; for (int i = 0; i < n; ++i){cin >> v[i];}
#define otp(v,n) for (int i = 0; i < n; ++i){cout << v[i]<<" ";}
#define ndl cout << endl;
#define ys cout << "YES" << endl
#define no cout << "NO" << endl
#define zer cout << 0 << endl
#define onee cout << 1 << endl
#define outp(a) cout << a << endl;
#define ret return 0;
#define pb push_back
#define all(arr) arr.begin(), arr.end()
#define rall(arr) arr.rbegin(), arr.rend()
#define min1 cout<<-1<<endl
#define f first
#define s second
#define int long long 
#define _test   int _TEST; cin>>_TEST; while(_TEST--)
#define M 1000000007
#define fir cout<<"first"<<endl;
#define sec cout<<"sec"<<endl;
#define ll long long 
string itos(int n ){vector<char>a;string s="" ;while(n){int b = n%10;a.insert(a.begin(),(char)b+48);n/=10;}for(auto x:a)s+=x;return s ;}

// set<string> storage;
// // vector<string> storage;
// void subs(int i , string s,string &x)
// {
//     if(i==x.size())storage.insert(s);
//     // if(i==x.size())storage.pb(s);
//     else{
//     string picked=s+x[i];
//     string skipped=s;

//     subs(i+1,picked,x);
//     subs(i+1,skipped,x);
//     }   
// }

// int lcs(string &s1, string &s2, int m, int n, vector<vector<int>> &memo) {

//         if(m==0 || n==0)return 0;

//         if(memo[m][n]!=-1)return memo[m][n];

//         if (s1[m - 1] == s2[n - 1])
            
//         return memo[m][n] = 1 + lcs(s1, s2, m - 1, n - 1, memo);

//         else {

//             return memo[m][n] = max(lcs(s1, s2, m - 1, n, memo),lcs(s1, s2, m, n-1, memo));

//         }

// }
// void solve()
// {
//     int    n ,  m ;
//     cin >> n >> m ; 
    
//     inp(v,n)      ;

//     vector<vector<int>>dp(n+1,vector<int>(m+1,0));
//     for (int i = 0; i < n; ++i)
//     {   
//         if(v[i]==0)
//         for (int j = 0; j <=m; ++j)
//         {
//             if(i==0 || i==n-1){if(abs(v[i]-j)<=1){dp[i][j]++;}}
//             else {
//                 if(abs(v[i-1]-j)<=1 &&abs(v[i+1]-j)<=1){dp[i][j]++;}
//             }
//         }
//     }

//     int cnt = 0 ;
//     for (int i = 0; i < dp.size(); ++i)
//     {
//         for (int j = 0; j <dp[i].size() ; ++j)
//         {
//             // cout << dp[i][j]<<" ";
//             cnt+=dp[i][j];
//         }
//         // ndl;
//     }

//     vector<vector<int>>cp=dp;


//     cout << x << endl;

// }   


void solve2()
{
    int lr , ur ; cin >> lr >> ur ;

    int x = 0 ;
    int y = 0 ;
    int z = 0 ;

    int l = 0 ;
    for (int i = 31; i >=0; --i)
    {
        if(((1<<i)&lr )&&(1<<i)&ur ){
            // cout << i << " ";
        x|=(1<<i);y|=(1<<i);}

        if(((1<<i)&ur) &&(((1<<i)&lr)==0)){l=i;y|=(1<<i);break;}
    }

    for (int i = l-1; i >=0 ; --i)
    {
        x|=(1<<i);
    }

    if(x-1!=y && x-1>=lr){z=x-1;}
    if(x+1!=y && x+1<=ur){z=x+1;}
    if(y-1!=x && y-1>=lr){z=y-1;}
    if(y+1!=x && y+1<=ur){z=y+1;}

    // ndl;
    cout << x <<" "<<y <<" "<<z<< endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
#ifndef ONLINE_JUDGE
 
    freopen("input.in", "r", stdin );
 
    freopen("output1.txt", "w", stdout);
 
    freopen("error.in", "w", stderr);
#endif
    _test
    solve2();   

}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define rep(i,a,b) for( long long i=a;i<( long long)b;i++)
#define F first
#define S second
#define pb push_back
#define yes() cout << "YES\n"
#define no() cout << "NO\n"
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<long long, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset; 

//bool comp(const pair<int,int>&a, const pair<int,int>&b){
//  return (a.f>b.f || (a.f==b.f && a.s<b.s));
//}

/*
//lowerbound
//imprime -1 si ningún valor cumple la condición
ll binsearchpos(ll mini, ll maxi){
    ll l=mini,r=maxi,ans=-1;
    
    while(l<=r){
        ll mid=l+(r-l)/2, target=0LL;
        ll f=gauss(mid-1)+(mid*k) - (gauss(n-1)+(n*k)-gauss(mid-1)-(mid*k));
        
        if(f>=target){
            //ans se actualiza si se cumple la condición
            ans=mid;
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    return ans;
}
*/  

const ll MOD=998244353;
 
long long binpow(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

void solve(){
    /*
        1 1 -> 0
        1 0 >1
        0 1 >1
        0 0 -> 0
        
        11 010001
        11 001111
        10 110000
        
        111
        111           
        000  

        010
        001
        000 
        after first dif (posdif)
        first eq after fd (poseq)
        if r[i]!=l[i]
        assign l[i]    
    */
    ll l,r;
    cin>>l>>r;

    ll k=0,e=-1,ans=0;
    for(int pot=31;pot>=0;pot--){
        ll mask=(1<<pot);

        if(!k && ((l&mask) != (r&mask))){
            k=pot;
            continue;
        }else if(!k){
            ans+=(l&mask);
            continue;    
        }

        if((l&mask) == (r&mask)){
            e=(l&mask);
            break;
        }
    }
    //cout<<k<<" "<<e<<"\n";
    for(int pot=k;pot>=0;pot--){
        ll mask=(1<<pot);

        if(!e){
            if((l&mask) != (r&mask)) ans+=(l&mask);
            else if(!(l&mask)) ans+=mask;
        }else{
            if((l&mask) != (r&mask)) ans+=(r&mask);
            else if(!(l&mask)) ans+=mask;
        }
    }

    if(ans==r) ans--;
    cout<<l<<" "<<r<<" "<<ans<<"\n";
    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int tt=1;
    cin>>tt;
    
    while(tt--){
        solve();
    }

    return 0;
}