import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break

    num=1<<(a-1)
    rbin=bin(r)[2:]

    # i=a-2
    # while(num-1<l or num-1>r):
    #     num+=(1<<i)
    #     i-=1
    # print(num-1,num,num+1)
    num=0
    o=0
    for i in range(len(rbin)):
        if(rbin[i]=="1"):
            num+=(1<<(len(rbin)-i-1))

        if(num-1>=l and num!=r):
            o=1
            break

        elif(num-2>=l):
            o=2
            break

    if(o==1):
        out=[num-1,num,num+1]
    else:
        out=[num-2,num-1,num]
    print(*out)

import sys,random,bisect,math
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

for _ in range(int(input())):
    l,r=mi()
    a=-1
    for i in range(31):
        if(1<<i >r):
            a=i
            break

    num=1<<(a-1)

    if(num>l and num<=r):
        # if(num==r):
        #     out=[num,num-1,num-2]
        # elif(num==l+1):
        #     out=[l,l+1,l+2]
        if(num==l+1):
            out=[l,l+1,l+2]
        else:
            out=[num,num-1,num-2]
    else:
        out=[r,r-1,r-2]
    print(*out)

Answer: 1


#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<functional>
//using namespace __gnu_pbds;
using namespace std;
#define ull unsigned long long
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(), v.end()
#define vec vector<ll>
#define pb push_back
#define Raftaar ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MEX LONG_LONG_MAX
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
/*

*/

void solve(){
	ll l,r;
	cin>>l>>r;
	ll a = l;
	ll b = r;

	ll c=0;
	rf(i,30,0){
		ll mask=(1<<i);
		if((a&mask)==0 && (b&mask)==0){
			c|=mask;
		}
		else if ((a&mask)==0 && (b&mask)!=0){
			c|=mask;
		}
	}
	if(c<l || c>r){
		if(l==r){
			c=l;
		}
		else{
			c=l+1;
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}

int main(){
	Raftaar
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<functional>
//using namespace __gnu_pbds;
using namespace std;
#define ull unsigned long long
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(), v.end()
#define vec vector<ll>
#define pb push_back
#define Raftaar ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MEX LONG_LONG_MAX
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
/*

*/

void solve(){
	ll l,r;
	cin>>l>>r;
	ll prev=0;
	ll a,b,c;
	rf(i,30,0){
		ll p=0,q=0;
		if(l & (1ll<<i)){
			p=1;
		}
		if(r & (1ll<<i)){
			q=1;
		}
		if(p==q){
			prev+=(p*(1ll<<i));
		}
		else{
			a=prev+(1ll<<i);
			b=a-1;
			break;
		}
	}
	f(i,l,r+1){
		if(i!=a && i!=b){
			c=i;
			break;
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}

int main(){
	Raftaar
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Answer: 2


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const int N=2e5+7;

void solved(){
    int  l,r;cin>>l>>r;
    int flag=0;
    int a=0,b=0,c=0;
    for(int i=30;i>=0;i--){
        int x=(l>>i)&1;
        int y=(r>>i)&1;
        int t=(1ll<<i);
        if(x==1 and y==1 and flag==0){
            a+=t;
            b+=t;
            c+=t;
            continue;
        }
        if((x==1 or y==1) and flag==0){
            flag=1;
            a+=t;
            b+=0;
            c+=0;
            continue;
        }
        if(flag){
            a+=0;
            b+=t;
            c+=t;
        }
    }
    if(r-l==2){
        cout<<l<<" "<<l+1<<" "<<l+2<<'\n';
        return;
    }
    if(b==c){
        c--;
    }
    cout<<a<<" "<<b<<" "<<c<<'\n';
}

signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--)solved();
}

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const int N=2e5+7;

void solved(){
    int  l,r;cin>>l>>r;
    int flag=0;
    int a=0,b=0,c=0;
    for(int i=30;i>=0;i--){
        int x=(l>>i)&1;
        int y=(r>>i)&1;
        int t=(1ll<<i);
        if(x==1 and y==1 and flag==0){
            a+=t;
            b+=t;
            c+=t;
            continue;
        }
        if((x==1 or y==1) and flag==0){
            flag=1;
            a+=t;
            b+=0;
            c+=0;
            continue;
        }
        if(flag){
            a+=0;
            b+=t;
            c+=t;
        }
    }
    if(r-l==2){
        cout<<l<<" "<<l+1<<" "<<l+2<<'\n';
        return;
    }
    if(b==c){
        if(c-1<l){
            a++;
            b++;
        }else{
            c--;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<'\n';
}

signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--)solved();
}

Answer: 2


use std::io;

fn main() {
    // Read the number of test cases
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let t: usize = input
        .trim()
        .parse()
        .expect("Failed to parse number of test cases");

    // Initialize a vector to hold the test cases
    let mut test_cases = Vec::new();

    // Read each test case
    for _ in 0..t {
        input.clear();
        io::stdin()
            .read_line(&mut input)
            .expect("Failed to read line");
        let nums: Vec<u32> = input
            .trim()
            .split_whitespace()
            .map(|x| x.parse().expect("Failed to parse number"))
            .collect();

        if nums.len() == 2 {
            test_cases.push((nums[0], nums[1]));
        } else {
            panic!("Each test case must contain exactly two numbers");
        }
    }

    // Process each test case
    for (l, r) in test_cases {
        // Replace this with your desired processing logic
        //println!("Processing range: {} to {}", l, r);

        /*
        let l_bin = to_binary(l);
        let r_bin = to_binary(r);
        println!("The binary representation of {} is {}", l, l_bin);
        println!("The binary representation of {} is {}", r, r_bin);
        let mut diff: u32 = r - l;
        let diff_bin = to_binary(diff);
        println!("The binary representation of {} is {}", diff, diff_bin);
        */

        let (mut pow2_bin, mut pow2) = max_power_of_2(l);
        //println!("pow2: {}, pow2_bin: {}", pow2, pow2_bin);

        let upper = r - pow2;
        let lower = l - pow2;
        //println!("lower: {}, upper: {}", lower, upper);
        let up_bin = to_binary(upper);

        //println!("upper: {} upper bin: {}", upper, up_bin);

        let inv_bin = invert_bits(&up_bin);
        //println!("The inverted binary is {}", inv_bin);
        let mut inv = binary_to_u32(&inv_bin).unwrap();
        //println!("inv: {}", inv);

        let mut c: u32 = pow2 + inv;
        if inv == 0 {
            c = l + 1;
        }

        println!("{} {} {}", l, c, r);
        //println!("------");
    }
}

fn to_binary(n: u32) -> String {
    format!("{:b}", n)
}

fn invert_bits(binary: &str) -> String {
    binary
        .chars()
        .map(|c| if c == '0' { '1' } else { '0' })
        .collect()
}

fn binary_to_u32(binary: &str) -> Option<u32> {
    u32::from_str_radix(binary, 2).ok()
}

fn max_power_of_2(l: u32) -> (String, u32) {
    if l == 0 {
        return ("0".to_string(), 0);
    }

    // Find the largest power of 2 less than or equal to l
    let pow2 = 1 << (31 - l.leading_zeros());

    // Convert the value to a binary string
    let binary_representation = format!("{:b}", pow2);

    // Return the binary string and u32 value
    (binary_representation, pow2)
}

use std::io;

fn main() {
    // Read the number of test cases
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let t: usize = input
        .trim()
        .parse()
        .expect("Failed to parse number of test cases");

    // Initialize a vector to hold the test cases
    let mut test_cases = Vec::new();

    // Read each test case
    for _ in 0..t {
        input.clear();
        io::stdin()
            .read_line(&mut input)
            .expect("Failed to read line");
        let nums: Vec<u32> = input
            .trim()
            .split_whitespace()
            .map(|x| x.parse().expect("Failed to parse number"))
            .collect();

        if nums.len() == 2 {
            test_cases.push((nums[0], nums[1]));
        } else {
            panic!("Each test case must contain exactly two numbers");
        }
    }

    // Process each test case
    for (l, r) in test_cases {
        // Replace this with your desired processing logic
        //println!("Processing range: {} to {}", l, r);

        /*
        Attempt 1
        let l_bin = to_binary(l);
        let r_bin = to_binary(r);
        println!("The binary representation of {} is {}", l, l_bin);
        println!("The binary representation of {} is {}", r, r_bin);
        let mut diff: u32 = r - l;
        let diff_bin = to_binary(diff);
        println!("The binary representation of {} is {}", diff, diff_bin);
        */

        /*
        Attempt 2

        let (mut pow2_bin, mut pow2) = max_power_of_2(l);
        //println!("pow2: {}, pow2_bin: {}", pow2, pow2_bin);

        let (_, pow2r) = max_power_of_2(r);
        if pow2 < pow2r {
            pow2 = l;
        }

        let upper = r - pow2;
        let lower = l - pow2;
        //println!("lower: {}, upper: {}", lower, upper);
        let up_bin = to_binary(upper);

        //println!("upper: {} upper bin: {}", upper, up_bin);

        let inv_bin = invert_bits(&up_bin);
        //println!("The inverted binary is {}", inv_bin);
        let mut inv = binary_to_u32(&inv_bin).unwrap();
        //println!("inv: {}", inv);

        let mut c: u32 = pow2 + inv;
        if inv == 0 {
            c = l + 1;
        }
        */

        /*
        Attempt 3. After reading editorial
        I kind of had that insight (two insights), but could not connect the two
        */

        let mut l_bin = to_binary(l);
        let r_bin = to_binary(r);

        // make it same length to compare
        l_bin = pad_binary(&l_bin, &r_bin);
        //println!("l_bin: {}, r_bin: {}", l_bin, r_bin);

        let n = l_bin.len();
        let mut k = n - 1;
        for i in 0..n {
            if l_bin.chars().nth(i) != r_bin.chars().nth(i) {
                break;
            }
            k -= 1;
        }
        //println!("most significant bit pos with difference: {}", k);

        let mut prefix: String = (&l_bin[0..n - k - 1]).to_string();
        //println!("prefix: {}", prefix);

        // append zeros:
        for i in 0..k + 1 {
            prefix.push('0');
        }

        //println!("after padding, prefix becomes: {}", prefix);
        let base = binary_to_u32(&prefix).unwrap();
        //println!("base additive: {}", base);

        let num1 = base + (1 << k); // 2^k
        let num2 = num1 - 1;
        let mut num3 = num1 + 1;
        if num3 > r {
            num3 = l;
        }

        println!("{} {} {}", num1, num2, num3);
        //println!("------");
    }
}

fn pad_binary(l_bin: &str, r_bin: &str) -> String {
    let l_len = l_bin.len();
    let r_len = r_bin.len();

    if l_len < r_len {
        let padding = "0".repeat(r_len - l_len);
        format!("{}{}", padding, l_bin)
    } else {
        l_bin.to_string() // Return l_bin as is if it's already the same length or longer
    }
}

fn to_binary(n: u32) -> String {
    format!("{:b}", n)
}

fn invert_bits(binary: &str) -> String {
    binary
        .chars()
        .map(|c| if c == '0' { '1' } else { '0' })
        .collect()
}

fn binary_to_u32(binary: &str) -> Option<u32> {
    u32::from_str_radix(binary, 2).ok()
}

fn max_power_of_2(l: u32) -> (String, u32) {
    if l == 0 {
        return ("0".to_string(), 0);
    }

    // Find the largest power of 2 less than or equal to l
    let pow2 = 1 << (31 - l.leading_zeros());

    // Convert the value to a binary string
    let binary_representation = format!("{:b}", pow2);

    // Return the binary string and u32 value
    (binary_representation, pow2)
}

Answer: 2


#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (x & (1 << i)) {
            k = i;
        }
    }
    int y = 0;
    for (int i = 0; i <= k; i++) {
        if ((x & (1 << i)) == 0) {
            y |= (1 << i);
        }
    }

    if (y < l)
        y |= l;

    if (y + 1 >= r) {
        cout << x << " " << y << " " << y - 1 << "\n";
    } else {
        cout << x << " " << y << " " << y + 1 << "\n";
    }
}

int main() {
    cin >> t;
    while (t--) solve();
}

#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    // int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (r & (1 << i)) {
            k = i;
        }
    }
    int base = 0;
    int start = -1;
    for (int i = k; i >= 0; i--) {
        if ((r & (1 << i)) != 0 && (l & (1 <<i)) != 0) {
            base |= (1 << i);
        } else if (r & (1 << i)) {
            start = i;
            break;
        }
    }

    int x = base + (1 << start);
    int y = base + (1 << start) - 1;
    int z = 0;
    if (x + 1 > r) {
        z = y - 1;
    } else {
        z = x + 1;
    }

    cout << x << " " << y << " " << z << "\n";

}

int main() {
    cin >> t;
    while (t--) solve();
}

Answer: 2


#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve(){
    ll l, r;
    cin >> l >> r;
    ll ans = 0;
    ll firstNum = 0, secondNum = 0;
    for (int i = 30; i >= 0; i--) {
        int b1 = 0, b2 = 0;
        if ((1 << i) & r) {
            b1 = 1;
        }
        if ((1 << i) & l) {
            b2 = 1;
        }

        if (b1 == b2) {
            ans += b1 * (1 << i);
        } else {
            firstNum += ans + (1 << i);
            secondNum += firstNum - 1;
            break;
        }
    }
    for (ll i = l; i <= r; i++) {
        if (i != firstNum && i != secondNum) {
            cout << i << " " << firstNum << " " << secondNum << '\n';
            break;
        }
    }
}

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve(){
    ll l, r;
    cin >> l >> r;
    ll ans = 0;
    ll firstNum = 0, secondNum = 0;
    for (int i = 30; i >= 0; i--) {
        int b1 = 0, b2 = 0;
        if ((1 << i) & r) {
            b1 = 1;
        }
        if ((1 << i) & l) {
            b2 = 1;
        }

        if (b1 == b2) {
            ans += b1 * (1 << i);
        } else {
            firstNum += ans + (1 << i);
            secondNum += firstNum - 1;
            break;
        }
    }
    for (ll i = l; i < r; i++) {
        if (i != firstNum && i != secondNum) {
            cout << i << " " << firstNum << " " << secondNum << '\n';
            break;
        }
    }
}

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

Answer: 1


#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    // int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (r & (1 << i)) {
            k = i;
        }
    }
    int base = 0;
    int start = -1;
    for (int i = k; i >= 0; i--) {
        if ((r & (1 << i)) != 0 && (l & (1 <<i)) != 0) {
            base |= (1 << i);
        } else if (r & (1 << i)) {
            start = i;
            break;
        }
    }

    int x = base + (1 << start);
    int y = base + (1 << start) - 1;
    int z = 0;
    if (x + 1 > r) {
        z = y - 1;
    } else {
        z = x + 1;
    }

    cout << x << " " << y << " " << z << "\n";

}

int main() {
    cin >> t;
    while (t--) solve();
}

#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int t;
int l, r;

void solve() {
    cin >> l >> r;
    int x = r;

    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (x & (1 << i)) {
            k = i;
        }
    }
    int y = 0;
    for (int i = 0; i <= k; i++) {
        if ((x & (1 << i)) == 0) {
            y |= (1 << i);
        }
    }

    // if (y < l)
    y |= l;

    if (y + 1 >= r) {
        cout << x << " " << y << " " << y - 1 << "\n";
    } else {
        cout << x << " " << y << " " << y + 1 << "\n";
    }
}

int main() {
    cin >> t;
    while (t--) solve();
}

Answer: 1


#include<bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define inf 1e9
#define nline "\n"
#define pb push_back
#define ppb pop_back
// #define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b)    for(int i{a};i<b;i++);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

//01111
//10000
//

void solve() {
    ll l = 0 , r = 0;
    cin >> l >> r;
    ll y = 1;
    int bit = 0;
    while (y <= r) {
        y = y * 2;
        bit++;
    }
    bit--;
    ll val = (1LL << bit);
    if (val > l && val <= r) {
        cout << val << " " << val - 1 << " ";
        if (l == val - 1) {
            cout << r << nline;
        }
        else cout << l << nline;
    }
    else {
        cout << l << " " << l + 1 << " " << r << nline;
        return;
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
    freopen("input.txt", "r", stdin);
#endif
    fastio();
    int t{1};
    cin >> t;
    while (t--) solve();
}

#include<bits/stdc++.h>
using namespace std;

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define inf 1e9
#define nline "\n"
#define pb push_back
#define ppb pop_back
// #define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b)    for(int i{a};i<b;i++);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

//01111
//10000
//

void solve() {
    ll l = 0 , r = 0;
    cin >> l >> r;
    ll y = 1;
    int bit = 0;
    while (y <=  r) {
        y = y * 2;
        bit++;
    }
    bit--;
    ll val = (1LL << bit);
    if (val > l && val <= r) {
        cout << val << " " << val - 1 << " ";
        if (l == val - 1) {
            cout << r << nline;
        }
        else cout << l << nline;
    }
    else {
        int bit = 0;
        for (int i = 30; i >= 0; i--) {
            int lbit = ((l & (1LL << i)) != 0);
            int rbit =  ((r & (1LL << i)) != 0);
            if (lbit != rbit) {
                bit = i;
                break;
            }
        }
        ll y = (l >> bit);
        y <<= bit;
        debug(y)
        debug(bit)
        debug(1LL << bit)
        ll gg =  (1LL << bit) + y;
        debug(gg)
        cout << gg << " " << gg - 1 << " ";
        if (gg - 1  == l ) {
            cout << r << nline;
        }
        else cout << l << nline;
    }
}
// 1000100
// 1100010

int main() {
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout);
    freopen("input.txt", "r", stdin);
#endif
    fastio();
    int t{1};
    cin >> t;
    while (t--) solve();
}

Answer: 2


#include<bits/stdc++.h>
using namespace std;
ifstream fin("window.in");
ofstream fout("window.out");
void solve(){
    int l,r;
    cin>>l>>r;
    int b(30),prc(0);
    while(((1<<b)&l)==((1<<b)&r))prc+=((1<<b)&r),b--;
    if(prc+(1<<b)==r)cout<<prc+(1<<b)<<" "<<prc+(1<<b)-1<<" "<<prc+(1<<b)-2<<"\n";
    else cout<<prc+(1<<b)<<" "<<prc+(1<<b)-1<<" "<<prc+(1<<b)+1<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long t;
    cin>>t;
    while(t--)solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
ifstream fin("window.in");
ofstream fout("window.out");
void solve(){
    int l,r;
    cin>>l>>r;
    int b(30);
    while(((1<<b)&l)==((1<<b)&r))b--;
    cout<<(1<<b)<<" "<<(1<<b)-1<<" "<<(1<<b)-1<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long t;
    cin>>t;
    while(t--)solve();
    return 0;
}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

ll inf = 1e18, mod = 1e9 + 7;

ll gcd(ll a, ll b) {
    while (a != 0 && b != 0) {
        if (a > b) {
            a %= b;
        }
        else {
            b %= a;
        }
    }
    return a + b;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

ll binpow(ll base, ll p) {
    if (p == 0) return 1;
    else if (p % 2) return binpow(base, p - 1) * base;
    else return binpow(base, p / 2) * binpow(base, p / 2);
}

void solve() {
    ll l, r;
    cin >> l >> r;
    ll cnt = 1, sz = 1;
    while (cnt * 2 <= r) {
        sz++;
        cnt *= 2;
    }
    cnt = 1;
    ll sz1 = 0;
    while (cnt * 2 <= l) {
        cnt *= 2;
        sz1++;
    }
    vector <int> bit, bit1;
    for (int i = 0; i < sz; ++i) {
        if (r & (1 << i)) bit.pb(1);
        else bit.pb(0);
    }
    ll s = 0;
    for (int i = 0; i < bit.size(); ++i) {
        if (!bit[i]) {
            bit1.pb(1);
            s += (1 << i);
        }
        else bit1.pb(0);
    }
    if (s >= l) {
        if (s & 1) {
            if (s - 1 < l) {
                cout << r << " " << s << " " << s + 1 << "\n";
            }
            else {
                cout << r << " " << s << " " << s - 1 << "\n";
            }
        }
        else {
            if (s + 1 >= r) {
                cout << r << " " << s << " " << s - 1 << "\n";
            }
            else {
                cout << r << " " << s << " " << s + 1 << "\n";
            }
        }
    }
    else {
        for (int i = sz1; i >= 0; --i) {
            if (!bit1[i] && s + (1 << i) <= r) {
                s += (1 << i);
                if (s >= l) break;
            }
        }
        if (s & 1) {
            if (s - 1 < l) {
                cout << r << " " << s << " " << s + 1 << "\n";
            }
            else {
                cout << r << " " << s << " " << s - 1 << "\n";
            }
        }
        else {
            if (s + 1 >= r) {
                cout << r << " " << s << " " << s - 1 << "\n";
            }
            else {
                cout << r << " " << s << " " << s + 1 << "\n";
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ull unsigned long long int
#define dl double long
#define all(x) x.begin(), x.end()
#define ss second
#define ff first
const int N = 2 * 1e5 + 10;
const int M = 1e9 + 7;
#define Priyanshu_Mishra

Priyanshu_Mishra

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = log2(r);
    if ((1ll << (x - 1)) >= l + 1) {
        cout << (1ll << (x)) << " " << (1ll << (x - 1)) << " " << (1ll << (x - 1)) - 1 << endl;
        return;
    }
    int a=(1ll<<x);
    int y = log2(r);
    int temp=(1ll<<(y+1))-1;
    int b=0;
    for (; y >= 0; y--) {
           if(((1ll<<y)&a)){
            if ((temp - (1ll << y)) > l) {
                temp-=(1ll << y);
            }
            else b+=(1ll<<y);
        }
        else if(b+(1ll<<y)<r)b+=(1ll<<y);
    }
    // if(b==0)b=l+1;
    int  c = b- 1;

    cout << a << " " << b << " " << c << endl;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcases = 1;
    cin >> testcases;
    while (testcases--)
    {
        solve();
        #ifdef Priyanshu_Mishra
        cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
        #endif
    }
    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int T, l, r;
void solve() {
    cin >> l >> r;
    bitset <32> x(l), y(r), ans(0);
    int tp = 31;
    for (; ~tp; tp --) if (x[tp] ^ y[tp]) break;
    for (int i = 31; i > tp; i --) ans[i] = x[i];
    for (int i = tp; ~i; i --) {
        if (!(x[i] ^ y[i])) ans[i] = x[i] ^ 1;
    }
    for (int i = tp; ~i; i --) {
        if (x[i] ^ y[i]) {
            ans[i] = 1;
            if (ans.to_ulong() >= y.to_ulong()) ans[i] = 0;
        }
    }
    int a = x.to_ulong(), b = ans.to_ulong(), c = y.to_ulong();
    cout << a << ' ' << b << ' ' << c << '\n';
}
int32_t main() {
    cin.tie(NULL) -> sync_with_stdio(false);
    for (cin >> T; T --; ) solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int ls, rs;
inline void slove() {
	int l, r; cin >> l >> r;
	int steps = 0, ans = 0;
	while (r >> steps) {
		ls = l >> steps & 1, rs = r >> steps & 1;
		if (ls != rs)
			if ((ans | (1 << steps)) <= r)ans |= (1 << steps);
		if (ls == rs)
			ans |= ((ls ^ 1) << steps);
		steps++;
	}
	cout << l<<" "<< ans<<" " << r << endl;
}
int main() {
	int T; cin >> T;
	while (T--) {
		slove();
	}
	return 0;
}

Answer: 1


#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int l, r;
    std::cin >> l >> r;

    int a = l, c = r, b = 0;
    bool ok = false;
    int pos;
    for (int i = 30; i >= 0; i --) {
        int x = a >> i & 1;
        int y = c >> i & 1;
        if (x ^ y) {
            pos = i;
            break;
        }
    }

    for (int i = 30; i > pos; i --) {
        int x = a >> i & 1;
        b += x << i;
    }

    for (int i = pos; i >= 0; i --) {
        int x = a >> i & 1;
        int y = c >> i & 1;
        if (x ^ y) {
            if (b + (1 << i) < c) {
                b += 1 << i;
            }
        } else {
            b += (!x) << i;
        }
    }

    std::cout << a << " " << b << " " << c << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(20);

    int T = 1;
    std::cin >> T;

    while (T --) {
        solve();
    }

    return 0;
}

// Author: Debjit Saha

#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define int long long
#define lld long double
// #define ll long long
#define endl '\n'
#define tab '\t'
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define vs vector<string>
#define mii map<int, int>
#define rep(n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=0;i<n;i++)
#define trev(x) for(auto it=x.begin(); it!=x.end(); it++)
#define yes(check) cout << (check ? "YES\n" : "NO\n")
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
const int mod=1e9+7;
// const int mod = 998244353;

void solve() {
	int l, r;
	cin >> l >> r;

	int sum = 0, p = 32, one = 1;
	while(p > 0) {
		int a = (l>>p) % 2;
		int b = (r>>p) % 2;
		if(a ^ b) {
			sum += (one<<p) - 1;
			break;
		}
		if(b) sum += (one<<p);
		p--;
	}
	// int a = sum+1, b = sum, c = sum-1;
	// int res = (a^b) + (b^c) + (c^a);
	if(sum-1 < l) sum++;
	cout << sum+1 << " " << sum << " " << sum-1 << " " << endl;
}

signed main() {
    fastIO;

    int t;
    cin >> t;
    while(t--)
        solve();
    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
#define int long long
typedef pair<int,int> pii;
typedef double db;
typedef long long LL;
const int N = 1e6+10;

void solve(){
    int l, r;
    cin >> l >> r;
    int op = 1;
    for (int i = 1 ; i <= 30; i  ++){
        op *= 2;
    }
    while(op){
        if(r / op && l / op == 0 ){
            if(r != op){
                cout << op + 1 << " " << op << " " <<  op - 1 << endl;
            }
            else {
                cout << op << " " << op - 1 << " " << op - 2 << endl;
            }
            return ;
        }
        op /= 2;
    }

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.tie(0);

    int _ = 1;
    cin>>_;
    while(_--)
    {
        solve();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
#define int long long
typedef pair<int,int> pii;
typedef double db;
typedef long long LL;
const int N = 1e6+10;

void solve(){
    int l, r;
    cin >> l >> r;
    int op = 1;
    for (int i = 1 ; i <= 30; i  ++){
        op *= 2;
    }
    int t = r;
    while(op){
        if(r / op && (l / op) == 0 ){
            //cout << "h" << endl;
            t /= op * 2;
            t *= op * 2;
            if(r != op){
                    op += t;
                cout << op   + 1<< " " << op << " " <<  op - 1  << endl;
            }
            else {
                op += t;
                cout << op << " " << op - 1 << " " << op - 2 << endl;
            }
            return ;
        }
        if(r /op && l / op){
            r %= op;
            l %= op;
        }
        //cout << op << " " << r / op << " " << (l / op) << endl;
        op /= 2;
    }

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.tie(0);

    int _ = 1;
    cin>>_;
    while(_--)
    {
        solve();
    }

    return 0;
}

Answer: 2


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define eb emplace_back

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z, ans=0;

        for(int i=30; i>=0; i--){
            int b1=0, b2=0;

            if(l & (1LL<<i)) b1=1;
            if(r & (1LL<<i)) b2=1;

            if(b1==b2){
                ans+=b1 * (1LL<<i);
            }

            else{
                x=ans+ (1LL<<i);
                break;
            }
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            }
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define eb emplace_back

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z;

        for(int i=r; i>=l; i--){
            if((i & i-1)==0){
                x=i;
                break;
            }
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            }
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}

	return 0;
}

Answer: 1


#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
// visit this link to study it in a proper way :
// https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds;
#define ordered_set  tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
// use less_equal for multiset and less for set ^
// Find by order and order of key
// cout<< *X.find_by_order(k)    <<endl;  //  K-th element in a set (counting from zero)
// cout<< X.order_of_key(k)   <<endl; //  Number of items strictly smaller than k.

using ll = long long;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int l,r;
    cin >> l >> r;
    int k = 31 - __builtin_clz( l ^ r );
    int a = ( l | ( (1 << k) - 1 ));
    int b = a + 1;
    int c = ( a == l ? r : l );
    cout << a << " " << b << " " << c << endl;
}

signed main() {
    auto begin = std::chrono::high_resolution_clock::now();

    // std::ifstream file("matrix.txt"); // Replace "input.txt" with your file name
    //     std::cerr << "Error opening file!" << std::endl;
    //     return 1;
    // }

    // std::string line;

    // while (std::getline(file, line)) { // Read the file line by line
    //     std::stringstream ss(line);    // Create a stringstream from the line
    //     std::string num;

    //     // Split the line by commas and extract integers
    //     while (std::getline(ss, num, ',')) {
    //         all.push_back(std::stoi(num)); // Convert the string to an integer and store it
    //     }
    // }

    // file.close();

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
        // cout << "-----" << endl;
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
// visit this link to study it in a proper way :
// https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds;
#define ordered_set  tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
// use less_equal for multiset and less for set ^
// Find by order and order of key
// cout<< *X.find_by_order(k)    <<endl;  //  K-th element in a set (counting from zero)
// cout<< X.order_of_key(k)   <<endl; //  Number of items strictly smaller than k.

using ll = long long;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int l,r;
    cin >> l >> r;
    cout << r << " " << l << " " << (l + r )/ 2 << endl;
}

signed main() {
    auto begin = std::chrono::high_resolution_clock::now();

    // std::ifstream file("matrix.txt"); // Replace "input.txt" with your file name
    //     std::cerr << "Error opening file!" << std::endl;
    //     return 1;
    // }

    // std::string line;

    // while (std::getline(file, line)) { // Read the file line by line
    //     std::stringstream ss(line);    // Create a stringstream from the line
    //     std::string num;

    //     // Split the line by commas and extract integers
    //     while (std::getline(ss, num, ',')) {
    //         all.push_back(std::stoi(num)); // Convert the string to an integer and store it
    //     }
    // }

    // file.close();

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
        // cout << "-----" << endl;
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}

Answer: 1


#include<bits/stdc++.h>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    if(r-l+1==3){
        cout<<l<<' '<<l+1<<' '<<l+2<<'\n';
        return ;
    }
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back((r>>i)&1);
            ans[1].push_back((r>>i)&1);
            ans[2].push_back((r>>i)&1);
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
        ans[2][30]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

#include<bits/stdc++.h>
#define int long long

using namespace std;
using ll=long long;

void solve(){
    int l,r;
    cin>>l>>r;
    int p=-1;
    vector<int> ans[3];
    for(int i=30 ; i>=0; i--){
        if((r&(1<<i))!=(l&(1<<i))){
            p=i;
            ans[0].push_back(0);
            ans[1].push_back(0);
            ans[2].push_back(1);
            break;
        }
        else{
            ans[0].push_back(r&(1<<i));
            ans[1].push_back(r&(1<<i));
            ans[2].push_back(r&(1<<i));
        }
    }
    bool flag=true;
    for(int i=p-1 ; i>=0; i--){
        if((l&(1<<i))==0){
            flag=false; ans[0].push_back(1); ans[1].push_back(0);
            ans[2].push_back(0);
        }
        else{
            ans[0].push_back(1); ans[1].push_back(1); ans[2].push_back(0);
        }
    }
    if(flag){
        for(int i=30,j=0; j<p ; j++,i--){
            ans[1][i]=0;
        }
        ans[1][30-p]=1;
    }
    vector<ll> res(3);
    for(int i=0,j=30 ; i<=30; i++,j--){
        for(int k=0; k<3 ; k++){
            res[k]+=(ll)(ans[k][i]<<j);
        }
    }
    for(int i=0; i<3 ; i++) cout<<res[i]<<' ';
    cout<<'\n';
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cout.tie(nullptr)->sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--) solve();
}

Answer: 1


#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int l, r;
    std::cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    std::cout << a << " " << b << " " << c << "\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define ln '\n'
#define ull unsigned  long long
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define ld long double
#define ss second
using namespace std;

void setIO(const string io="a"){
    freopen((io+".in").c_str(),"r",stdin) ;
    freopen((io+".out").c_str(),"w",stdout) ;
}
void f(ll a,ll b,ll c){
	cout << (a^b) + (a^c) + (b^c) << ln ;
}

void solve(){
	ll l , r ; cin >> l >> r ;
	ll n = log2(r)+1 ;
	string s1 = "" ; for(ll i=0;i<n;i++) s1 += '0' ;
	ll a = r , i = n-1 ;
	while(a){
		if ((a&1ll)) s1[i] = '1' ;
		a>>= 1ll ; i-- ;
	}
	string s2 = "" ; for(ll i=0;i<n;i++) s2 += '0' ;
	ll b = l ;  i = n-1 ;
	while(b){
		if ((b&1ll)) s2[i] = '1' ;
		b>>= 1ll ; i-- ;
	}
	string s3 = "" ; for(ll i=0;i<n;i++) s3 += '0' ;
	ll pow = n-1 , val3 = 0 ;
	for(ll i=0;i<n;i++){
		if (val3+(1ll<<pow)> r ) {
			pow-- ; continue ;
		}
		else if (val3 + (1ll<<pow)-1<l) s3[i] = '1'  ,val3 += (1ll<<pow);
		else if (s1[i]=='0' and s2[i]=='0') s3[i] = '1' , val3 += (1ll<<pow);
		pow-- ;
	}
	if (l==val3) val3++ ;
	//cout << s1  << " " << s2 <<  " " << s3 << ln ;
	cout << r << " " <<  l<< " " << val3 << ln ;
	//f(r,l,val3) ;
	return ;
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	setIO() ;
	ll t = 1 ;
	cin >> t ;
	for(ll i=1;i<=t;i++){
		//cout << "Case " << i << ": " ;
		solve() ;
	}
    return 0;
}

Answer: 1


#include<bits/stdc++.h>
using namespace std;

void __solve(){
  int l,r;
  cin>>l>>r;
  int k=31- __builtin_clz(l^r);
  int a=l|((1<<k) -1);
  int b=a+1;
  int c=(a==l)?r:l;
  cout<<c<<" "<<a<<" "<<b<<'\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int t=1;
  cin>>t;
  while(t--){
    __solve();
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;

void __solve(){
  int l,r;
  cin>>l>>r;
  int k=31- __builtin_clz(l^r);
  int a=l|(1<<k -1);
  int b=a+1;
  int c=(a==l)?r:l;
  cout<<c<<" "<<a<<" "<<b<<'\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int t=1;
  cin>>t;
  while(t--){
    __solve();
  }

  return 0;
}

Answer: 1


#include <bits/stdc++.h>

#define int long long
#define debug(x) std::cerr<<"The "<<#x<<" = "<<x<<'\n';

using i128 = __int128;
using i64 = long long;
using u64 = unsigned long long;

constexpr int N = 1e6 + 5;
constexpr int mod = 998244353;
constexpr i64 INF = 0x7fffffffffffffffLL;

void solve() {
    int l, r;
    std::cin >> l >> r;
    int now = 0;
    for (int i = 30; i >= 0; i--) {
        if ((l >> i & 1) != (r >> i & 1)) {
            int x = (1LL << i) - 1, y = 0;
            x += now, y += now + (1LL << i);
            std::cout << x << " " << y << " " << ((x != l && y != l) ? l : r) << '\n';
            return ;
        }
        now += ((l >> i & 1) ? (1LL << i) : 0);
    }
}

signed main() {
    std::ios::sync_with_stdio(false),
    std::cin.tie(0),
    std::cout.tie(0);
    int T = 1;
    std::cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define ll long long
unordered_set<ll>sett;
int main()
{
    ll t;
    cin>>t;
    for(ll k1=1;k1<=t;k1++)
    {
        ll i,j,k,cnt1=0,cnt2=0,l,r;
        cin>>l>>r;
        ll base=r;
        while(base>0) base/=2,cnt1++;
        for(i=cnt1;i>=1;i--)
        {
            base=pow(2,i-1);
            ll x=r/base;
            x*=base;
            if(x>l)
            {
                if(x!=r) cout<<x<<" "<<x-1<<" "<<x+1<<endl;
                else cout<<x<<" "<<x-1<<" "<<x-2<<endl;
                break;
            }
        }
    }
}

Answer: 1


#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        while( x % z == 0 ) {
            z *= 2 ;
        }
        z /= 2 ;
        x = z ;
        z *= (r/z) ;
        if(z<=l) {
            z +=x ;
        }
        ll a1 = z , a2 = z - 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        int k = 31 - __builtin_clz(l ^ r);
        z = 1 << k ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3 ;
        if(a1 == l) {
            a3 = r ;
        }else {
            a3 = l ;
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

Answer: 2


def read_list():
    return list(map(int, input().split()))

class Solution:
    def solve(self):
        l, r = tuple(read_list())

        t = 1
        while t * 2 <= r:
            t *= 2

        rm = 0
        while l >= t:
            l -= t
            r -= t
            rm += t
            t //= 2

        if l < t - 1:
            print(l + rm, t - 1 + rm, r + rm)
        elif l == t - 1:
            print(l + rm, t + rm, r + rm)

if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()

def read_list():
    return list(map(int, input().split()))

def f(a, b, c):
    return (a ^ b) + (b ^ c) + (c ^ a)

class Solution:
    def solve(self):
        l, r = tuple(read_list())
        L = l
        R = r
        lb = []
        rb = []
        for _ in range(32):
            lb.append(l % 2)
            l //= 2
            rb.append(r % 2)
            r //= 2
        for i in range(31, -1, -1):
            if lb[i] != rb[i]:
                assert lb[i] == 0 and rb[i] == 1
                X = L | ((1 << i) - 1)
                if L < X:
                    print(L, X, X + 1)
                else:
                    print(X, X + 1, X + 2)
                break

if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()

Answer: 2


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e8 ;
int main() {

ios_base::sync_with_stdio(false); cin.tie(NULL);

ll tt ; cin >> tt ;

while(tt--) {

    ll l , r ; cin >> l >> r ;

    ll a = 0 , b = 0 ;
    ll ind = -1 ;
    for( int i = 30 ; i >= 0 ; i--) {

            if((l & (1 << i)) != (r & (1 << i)) ) {
                ind = i ; break;
            }
            if(l & (1 << i)) {
                a += (1 << i) ;
                b = a;
            }
        }
    a += (1 << ind) ;
    ind--;
    for( int i = ind ; i >= 0; i--) {
        b += (1 << i) ;
    }
    ll c ;
    for( int i = l ; i <= r ; i++) {
        if(i != a && i != b) {
            c = i ; break;
        }
    }
    cout << a << " " << b << " " << c << "\n" ;
    }
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e8 ;
int main() {

ios_base::sync_with_stdio(false); cin.tie(NULL);

ll tt ; cin >> tt ;

while(tt--) {

    ll l , r ; cin >> l >> r ;

    ll a = 0 , b = 0 , c = 0 ;
    ll ind = -1 ;
    for( int i = 30 ; i >= 0 ; i--) {

            if((l & (1 << i)) != (r & (1 << i)) ) {
                ind = i ; break;
            }
            if(l & (1 << i)) {
                a += (1 << i) ;
                c = b = a;
            }
        }
    a += (1 << ind) ;
    ind--;
    for( int i = ind ; i >= 0; i--) {
        b += (1 << i) ;
        if(i) c += (1 << i) ;
    }
    cout << a << " " << b << " " << c << "\n" ;
    }
}

Answer: 1


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define mapi map<int,int>
#define mapll map<ll,ll>
#define yes cout << "YES\n"
#define no cout<<"NO\n"
#define fori_n for(int i = 0; i<n; i++)
#define prans cout<<ans<<"\n";
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while(t--){
        ll l, r;
        cin >> l >> r;
        ll x = round(powl(2, (ll)log2l(r)));
        ll y = x, sum = 0;
        while(y){
            if(sum+y-1>=l && sum+y>=l && sum+y<=r){
                break;
            }
            if(sum+y<=r)
            sum+=y;
            y/=2;
        }
        x = sum+y-1;
        y+=sum;
        ll z;
        if(r==y){
            z = r-2;
        }
        else z = r;
        cout << x << " " << y << " " << z << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define int long long
using namespace std;

void solve() {
	int l, r;
	cin >> l >> r;
	int idx = -1;
	int mid = 0;
	for (int i=30;i>=1;i--) {
		int a = l & (1 << i);
		int b = r & (1 << i);
		if (a == b) {
			idx = i;
			if (a > 0) mid += (1 << i);
		} else {
			break;
		}
	}
	mid += (1 << (idx-1));
	if (mid - 1 == l) {
		cout << l  << " " << mid + 1 << " " << mid << endl;
	} else {
		cout << l  << " " << mid - 1 << " " << mid << endl;
	}

//	int mid = 1;
//	while (mid * 2 <= r) {
//		mid = mid * 2;
//	}
//	if (l + 1 < mid) {
//		cout << l  << " " << mid - 1 << " " << mid << endl;
//	} else if (l == mid - 1) {
//		cout << l  << " " << mid << " " << r << endl;
//	} else {
//		// l >= mid
//
//		cout << endl;
//	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Answer: 1


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <set>

#include <map>
#include <cctype>
#include <cstdio>
#include <numeric>
#define ll long long
#define LOG2(n) __lg(n)
#define SET_BIT_COUNTLL(x) __builtin_popcountll(x)
#define SET_BIT_COUNT(x) __builtin_popcount(x)
#define FAST ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define lp(var,inti,size) for(int var = inti ; var < size ; var ++)
#define fori(size) for(ll i=0; i < (size); i++)
#define foril(size) for(ll i=(size-1); i >= 0; --i)
#define forj(size) for(ll j=0; j < (size); j++)
#define fork(size) for(ll k=0; k < (size); k+= 1)
#define forl(size) for(ll l=0; l < (size); l+= 1)
const float pi = 3.14;
const long long oo = 9223372036854775807;
using namespace std;
#define oo 1e9
#define pb push_back
#define endll "\n"
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define yes cout<<"YES"<<endll
#define no cout<<"NO"<<endll

const ll MOD = 1e9 + 7, MOD2 = 1e9 + 9;
const ll N = 1e6 + 9;
using namespace std;

typedef pair<ll, ll> pii;
typedef pair<ll, pii> ppi;
typedef vector<ll> vec;
void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

vector<ll> fibNumbers(1e7, 1);

set<ll> primeo;

ll  dpadep(vec &dpadepo, ll fo) {
    if (fo > 1000)return 0;
    else {
        dpadepo.push_back(fo);
        dpadep(dpadepo, fo * 10 + 7);
        return dpadep(dpadepo, fo * 10 + 4);
    }

}
void TT() {

    long long n, t, m = 0, c = 0, sum = 0, real_sum = 0, c_sofar = 0, sum_sofar = 0; ll a, b = 1, k, r, l, ans = 0;
    string sl,sr;
    cin >>l>>r;
    vec x; t = l;
    map <ll, ll>lolo;
    while (l) {
        if (l % 2)sl =  sl+"1"  ;
        else sl = sl +"0"  ;
        l = l/ 2;
   }
    while (r) {
        if (r % 2)sr =  sr+"1";
        else sr =  sr +"0" ;
        r = r / 2;
    }
    if (sr.length() > sl.length()) {
        if (((1 << sr.length() - 1) - 1) != t)   cout << (1 << sr.length() - 1) << " " << (1 << sr.length() - 1) - 1 << " " << t << endl;
        else cout << t << " " << t + 1 << " " << t + 2<<endl;
    }
    else {
        c = sr.length()-1;
        while (sr[c] == sl[c]) {
            if (sr[c] - '0')ans += (1ll << c);
            c--;

        }
       if(t!=ans+( (1ll << c) - 1 )) cout << ans+(1ll << c) << " " << ans+(1ll << c) - 1 << " " << t << endl;
       else cout << ans+(1ll << c) << " " << ans+(1ll << c) + 1 << " " <<
           t << endl;
    }

}

/* if (b > n) {         QWE
        cout << n << endl;;
    }
    else if (a) {
        ans = n - 1 - b+a;
        ans /= a;
        cout <<n- ans << endl;
    }
    else {

        if (n == 1) {
            if (b)cout << 1<<endl;
            else cout << 0 << endl;;
        }
        else if(b) cout << n - 1 << endl;
        else  cout << -1 << endl;;
    }*/

int main() {
    fast();

    int n = 1;
    cin >> n;
    ll s = 0;
    while (n--) { TT();  }
}
// Owvx

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <set>

#include <map>
#include <cctype>
#include <cstdio>
#include <numeric>
#define ll long long
#define LOG2(n) __lg(n)
#define SET_BIT_COUNTLL(x) __builtin_popcountll(x)
#define SET_BIT_COUNT(x) __builtin_popcount(x)
#define FAST ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define lp(var,inti,size) for(int var = inti ; var < size ; var ++)
#define fori(size) for(ll i=0; i < (size); i++)
#define foril(size) for(ll i=(size-1); i >= 0; --i)
#define forj(size) for(ll j=0; j < (size); j++)
#define fork(size) for(ll k=0; k < (size); k+= 1)
#define forl(size) for(ll l=0; l < (size); l+= 1)
const float pi = 3.14;
const long long oo = 9223372036854775807;
using namespace std;
#define oo 1e9
#define pb push_back
#define endll "\n"
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define yes cout<<"YES"<<endll
#define no cout<<"NO"<<endll

const ll MOD = 1e9 + 7, MOD2 = 1e9 + 9;
const ll N = 1e6 + 9;
using namespace std;

typedef pair<ll, ll> pii;
typedef pair<ll, pii> ppi;
typedef vector<ll> vec;
void fast() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

vector<ll> fibNumbers(1e7, 1);

set<ll> primeo;

ll  dpadep(vec &dpadepo, ll fo) {
    if (fo > 1000)return 0;
    else {
        dpadepo.push_back(fo);
        dpadep(dpadepo, fo * 10 + 7);
        return dpadep(dpadepo, fo * 10 + 4);
    }

}
void TT() {

    long long n, t, m = 0, c = 0, sum = 0, real_sum = 0, c_sofar = 0, sum_sofar = 0; ll a, b = 1, k, r, l, ans = 0;
    string sl,sr;
    cin >>l>>r;
    vec x; t = l;
    map <ll, ll>lolo;
    while (l) {
        if (l % 2)sl = "1" + sl;
        else sl = "0" + sl;
        l = l/ 2;
   }
    while (r) {
        if (r % 2)sr = "1" + sr;
        else sr = "0" + sr;
        r = r / 2;
    }
    if (sr.length() > sl.length()) {
        if (((1 << sr.length() - 1) - 1) != t)   cout << (1 << sr.length() - 1) << " " << (1 << sr.length() - 1) - 1 << " " << t << endl;
        else cout << t << " " << t + 1 << " " << t + 2<<endl;
    }
    else {
        c = sr.size()-1;
        while (sr[c] == sl[c]) {
            if (sr[c] - '0')ans += (1ll << c);
            c--;

        }
       if(t!=ans+( (1ll << c) - 1 )) cout << ans+(1ll << c) << " " << ans+(1ll << c) - 1 << " " << t << endl;
       else cout << ans+(1 << c) << " " << ans+(1 << c) + 1 << " " <<
           t << endl;
    }

}

/* if (b > n) {         QWE
        cout << n << endl;;
    }
    else if (a) {
        ans = n - 1 - b+a;
        ans /= a;
        cout <<n- ans << endl;
    }
    else {

        if (n == 1) {
            if (b)cout << 1<<endl;
            else cout << 0 << endl;;
        }
        else if(b) cout << n - 1 << endl;
        else  cout << -1 << endl;;
    }*/

int main() {
    fast();

    int n = 1;
    cin >> n;
    ll s = 0;
    while (n--) { TT();  }
}
// Owvx

Answer: 1


// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

void solve(){
	int l,r;
	cin>>l>>r;
	int k= 31 - __builtin_clz(r^l);
	int a= l | ((1<<k)-1), b=a+1, c = ((a==l)? r: l);
	cout<<a<<" "<<b<<" "<<c<<endl;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define endl '\n'
#define fora(a) for(auto i:a)cout<<i<< ' ';cout<<endl
#define form(a) for(auto i:a)cout<<i.first<< ' '<<i.second<<endl
#define maxc(i) *max_element(i.begin(),i.end())
#define minc(i) *min_element(i.begin(),i.end())
#define All(i) i.begin(),i.end()
#define Rall(i) i.rbegin(),i.rend()
#define INF (long long) 1.01e18
#define MOD 1000000007
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0)

//-------------------------------PREPROCESSORS-------------------------------------

class SegmentTree {
    vector<int> tree, lazy;
    int n;

public:
    SegmentTree(int size) {
        n = size;
        tree.resize(4 * n, 0);
        lazy.resize(4 * n, 0);
    }

    void build(vector<int>& arr, int start, int end, int node) {
        if (start == end) {
            tree[node] = arr[start];
            return;
        }

        int mid = (start + end) / 2;
        build(arr, start, mid, 2 * node + 1);
        build(arr, mid + 1, end, 2 * node + 2);
        tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
    }

    void updateRange(int start, int end, int l, int r, int value, int node) {
        if (lazy[node] != 0) {
            tree[node] += (end - start + 1) * lazy[node];
            if (start != end) {
                lazy[2 * node + 1] += lazy[node];
                lazy[2 * node + 2] += lazy[node];
            }
            lazy[node] = 0;
        }

        if (start > end || start > r || end < l) {
            return;
        }

        if (start >= l && end <= r) {
            tree[node] += (end - start + 1) * value;
            if (start != end) {
                lazy[2 * node + 1] += value;
                lazy[2 * node + 2] += value;
            }
            return;
        }

        int mid = (start + end) / 2;
        updateRange(start, mid, l, r, value, 2 * node + 1);
        updateRange(mid + 1, end, l, r, value, 2 * node + 2);
        tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
    }

    int queryRange(int start, int end, int l, int r, int node) {
        if (start > end || start > r || end < l) {
            return 0;
        }

        if (lazy[node] != 0) {
            tree[node] += (end - start + 1) * lazy[node];
            if (start != end) {
                lazy[2 * node + 1] += lazy[node];
                lazy[2 * node + 2] += lazy[node];
            }
            lazy[node] = 0;
        }

        if (start >= l && end <= r) {
            return tree[node];
        }

        int mid = (start + end) / 2;
        int left = queryRange(start, mid, l, r, 2 * node + 1);
        int right = queryRange(mid + 1, end, l, r, 2 * node + 2);
        return left + right;
    }

    void updateRange(int l, int r, int value) {
        updateRange(0, n - 1, l, r, value, 0);
    }

    int queryRange(int l, int r) {
        return queryRange(0, n - 1, l, r, 0);
    }
};

class Manacher {
public:
    string longestPalindrome(string s) {
        string t="$";
        for(char i: s){
            t+='#';
            t+=i;
        }
        t+="#@";
        int n=t.size();
        int main_palindrome_center=1, main_palindrome_right_bound=1;
        vector<int> palindrome_length(n,0);
        for(int i=1;i<n;i++){

            // finding mirror index
            // let say main_palindrome_center as c, (i-c) => gives difference then reduce that from c which makes c-(i-c)
            // c-i+c => 2*c -i
            int mirror_character_index= main_palindrome_center*2 - i;

            if(i< main_palindrome_right_bound){
                // if i is inside the boundary, then atleast guarentee length should be
                // palindrome_length of mirror but it may exceeds the right boundary
                // so remove the string beyond the right boundary by
                palindrome_length[i]= min(
                    palindrome_length[mirror_character_index],
                    main_palindrome_right_bound-i);
            }

            while(
                t[i + (palindrome_length[i]+1)] == t[i- (palindrome_length[i]+1)]
            ){
                palindrome_length[i]++;
            }

            if((i+ palindrome_length[i]) > main_palindrome_right_bound){
                main_palindrome_right_bound = palindrome_length[i]+i;
                main_palindrome_center = i;
            }
        }
        int max_length=0, index=0;
        for(int i=1;i<n;i++){
            if(max_length<=palindrome_length[i]){
                max_length= palindrome_length[i];
                index=i;
            }
        }
        string longest_palindrome_string="";
        for(int i=index-max_length;i<index+max_length;i++){
            if(t[i]=='#')continue;
            longest_palindrome_string+=t[i];

        }

        return longest_palindrome_string;
    }
    // watch this video, if you have doubts https://www.youtube.com/watch?v=nbTSfrEfo6M
};

int bpow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1)
            res=res%MOD*1ll*(a%MOD)%MOD;
        a=a%MOD*1ll*(a%MOD)%MOD;
        b>>=1;
    }
    return res;
}
template <typename T>
T nxt() {
    T x;
    cin >> x;
    return x;
}

void solve(){
  int l,r;
  cin>>l>>r;
  int k= 31- __builtin_clz(r);
  int a= 1<<k, b= a-1, c= (b==l)? r: l;
  cout<<a<<" "<<b<<" "<<c<<endl;

}

signed main() {
    fastio();
    int test=1;
    cin>>test;
    for(int i=1;i<=test;i++){
      // cout<<"case #"<<i<<": ";
      solve();
    }

    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;
void solve()
{
long long l,r;
cin>>l>>r;
long long ans=0;
long long a,b,c;
for(int i=30;i>=0;i--){
  long long b1 = (l&(1<<i));
  long long b2 = (r&(1<<i));
  if(b1==b2){
    ans += b1*(1<<i);
  }else {
    a = ans + (1<<i);
    b = a-1;
  }
}
for(long long i = l ;i<=r;i++){
  if(i!=a && i!=b) {
    c= i;
    break;
    }

}
cout<<a<<" "<<b<<" "<<c<<"\n";

}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int t = 1;
    cin >> t;
    // cout<<t<<endl;
    while (t--)
    {
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
void solve()
{
long long l,r;
cin>>l>>r;
long long ans=0;
long long a,b,c;
for(int i=30;i>=0;i--){
  long long b1=0,b2=0;
  if(l&(1LL<<i)) b1 =1 ;
  if(r&(1LL<<i)) b2 =1 ;
  if(b1==b2){
    ans += b1*(1LL<<i);
  }else {
    a = ans + (1LL<<i);
    b = a-1;
    break;
  }
}
for(long long i = r ;i>=l;i--){
  if(i!=a && i!=b) {
    c= i;
    break;
    }

}
cout<<a<<" "<<b<<" "<<c<<"\n";

}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int t = 1;
    cin >> t;
    // cout<<t<<endl;
    while (t--)
    {
        solve();
    }
    return 0;
}

Answer: 2


#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        int k = 31 - __builtin_clz(l ^ r);
        z = 1 << k ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3 ;
        if(a1 == l) {
            a3 = r ;
        }else {
            a3 = l ;
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <math.h>
#include <set>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll  long long
// const ll MOD = 998244353 ;
// inline ll mul(ll a1, ll a2) { return ((a1 * a2) % MOD); }
// inline ll sum(ll a1, ll a2) { return ((a1 + a2) % MOD); }
// inline ll sub(ll a1, ll a2) { return  ((a1 - a2 + MOD) % MOD); }
int main() {
    IOS
    int test ;
    cin>>test;
    while(test--) {
        ll l , r ;
        cin>>l>>r;
        ll z = 1 ,  x = l ^ r ;
        while( x % z == 0 ) {
            z *= 2 ;
        }
        z /= 2 ;
        ll a1 = l | (z-1) , a2 = a1 + 1 , a3;
        ll max = -1  ;
        for( int i = l ; i <= r ; i++ ) {
            if ((i==a1)or(i==a2)) {
                continue ;
            }
            if ((i^a1)+(i^a2)>max) {
                max = i^a1 + i^a2 ;
                a3 = i ;
            }
        }
        cout<<a1<<" "<<a2<<" "<<a3<<endl;
    }
    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define fst first
#define scd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
using vi = vector<int>;
using vl = vector<ll>;
const ll INF = 1e18 + 7;
const int N = 5e6 + 7;
const int M = 5e8 + 7;
const int modN = 998244353;
mt19937_64 rng(time(0));

ll a[N];

void solve(){
    ll l, r;
    cin >> l >> r;
    ll num = log2(r);
    ll cur = 1ll << num;
    num--;
    while(cur <= l && num >= 0){
        if(cur + (1ll << num) <= r)
            cur += (1ll << num);
        num--;
    }
    cout << cur << " " << cur - 1 << " ";
    if(cur != r)
        cout << r << "\n";
    else
        cout << l << "\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll T;
    cin >> T;
    while(T--)
        solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define fst first
#define scd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
using vi = vector<int>;
using vl = vector<ll>;
const ll INF = 1e18 + 7;
const int N = 5e6 + 7;
const int M = 5e8 + 7;
const int modN = 998244353;
mt19937_64 rng(time(0));

ll a[N];

void solve(){
    ll l, r;
    cin >> l >> r;
    ll num = log2(r);
    ll cur = 1ll << num;
    num--;
    while((cur + 1ll << num) <= l && num >= 0){
        if(cur + (1ll << num) <= r)
            cur += (1ll << num);
        num--;
    }
    cout << cur << " " << cur - 1 << " ";
    if(cur != r)
        cout << r << "\n";
    else
        cout << l << "\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll T;
    cin >> T;
    while(T--)
        solve();
    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define srt(x) sort(x.begin(),x.end());
#define print(x) for(int i = 0;i<x.size();i++)cout<<x[i]<<" ";cout<<"\n";

void solve() {
    int l,r;
    cin >> l >> r;
    int j = 0;
    int a = 0 , b = 0, c = 0;
    for(int i = 30;i>=0;i--){
        if((l&(1<<i))!=(r&(1<<i))){
            // both bits different
            j = i;
            break;
        }else{
            // same bits
            int x = l&(1<<i);
            a += (x << (i-1));
            b += (x << (i-1));
        }
    }
    a<<=1;
    for(int i = j-1;i>=0;i--){
        a<<=1;
        a+=1;
    }
    b <<= 1;
    b+=1;
    for(int i = j-1;i>=0;i--){
        b<<=1;
    }
    for(int i = l;i<=r;i++){
        if(a!=i && b!=i){
            c = i;
            break;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int _t;
    cin >> _t;
    while(_t--){
        solve();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define srt(x) sort(x.begin(),x.end());
#define print(x) for(int i = 0;i<x.size();i++)cout<<x[i]<<" ";cout<<"\n";

void solve() {
    int l,r;
    cin >> l >> r;
    int j = 0;
    int a = 0 , b = 0, c = 0;
    for(int i = 30;i>=0;i--){
        if((l&(1<<i))!=(r&(1<<i))){
            // both bits different
            j = i;
            break;
        }else{
            // same bits
            int x = 0;
            if(l&(1<<i))x = 1;
            a += x*(1<<i);
            b += x*(1<<i);
        }
    }
    int x = 1;
    for(int i = j-2;i>=0;i--){
        x<<=1;
        x+=1;
    }
    a+=x;
    b+=(1<<(j));
    for(int i = l;i<=r;i++){
        if(a!=i && b!=i){
            c = i;
            break;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int _t;
    cin >> _t;
    while(_t--){
        solve();
    }

    return 0;
}

Answer: 2


for _ in range(int(input())):
    b, a = map(int, input().split())
    k = (1 << ((a^b).bit_length()-1)) - 1
    print(b | k, b | k, a & (~k))

for _ in range(int(input())):
    b, a = map(int, input().split())
    k = (1 << ((a^b).bit_length()-1)) - 1
    if (b|k == b):
        m = (b|k)+2
    else:
        m = (b | k) -1
    print(b | k, m, (b | k) +1)

Answer: 2


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;

   if(r - l == 2){
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
    return;
   }
   int ans = 0;
   while(1){
    int x = 1;
    while(x*2 <= r)x *=2;
    if(x <=l){
        ans +=x;
        r -=x;
        l -=x;
        continue;
    }
    if(x == r)cout<<x + ans<<' '<<x + ans-1<<' '<<l+ans<<endl;
    else cout<<x + ans<<' '<<x + ans-1<<' '<<r+ans<<endl;
    return;

   }

}

signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_;
    while(_--)solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i ,a ,b) for(int i =a;i<=b;++i)
#define endl '\n'
#define debug(a) cout<<#a<<'='<<a<<endl;
#define inf 0x3f3f3f3f
#define ls u<<1
#define rs u<<1|1
typedef pair<int,int> pii;
int ksm(int a , int b){
	int res = 1;
	while(b){
		if(b&1) res = res * a ;
		b >>= 1;
		a = a * a ;
	}
	return res;
}
void solve(){
   int l , r;
   cin>>l>>r;
   int cnt = 0;
   int ans = 0;
   while(1){
    if(ksm(2 , cnt) <= r){
        ans = ksm(2 , cnt);
        cnt++;
    }
    else{
        break;
    }

   }

   if(ans -2 >= l){
    cout<<ans<<' '<<ans-1<<' '<<l<<endl;
    return;
   }
    if(r - l >= 5){
        cout<<l<<' '<<l+2<<' '<<l+2+3<<endl;
        return;
    }
    cout<<l<<' '<<l+1<<' '<<l+2<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int _ = 1;
    cin>>_;
    while(_--)solve();
    return 0;
}

Answer: 1


#include<bits/stdc++.h>
using namespace std;
int T,l,r,x;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;while(T--){
		cin>>l>>r;
		for(int i=29;i;i--)
			if(((l>>i)^(r>>i))&1){
				x=(r>>i|1)<<i;
				cout<<x<<' ';
				cout<<x-1<<' ';
				if(x==r)cout<<l<<'\n';
				else cout<<r<<'\n';
				break;
			}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int T,l,r,x;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;while(T--){
		cin>>l>>r;
		for(int i=29;i;i--)
			if(((l>>i)^(r>>i))&1){
				x=(r>>i|1)<<i;
				cout<<x<<' ';
				cout<<x-1<<' ';
				cout<<x-1<<'\n';
				break;
			}
	}
	return 0;
}

Answer: 1


#include "bits/stdc++.h"
using namespace std;
#define all(v) v.begin(), v.end()
#define debug(x) cout<< #x<<'='<<x<<endl;
#define ll long long
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;
    while(t--){
     int l,r;
     cin >> l >> r;
     int temp = 0;
     for(int i = 30; i >= 0; i--){
         if(((l>>i)&1))temp^=(1<<i);
         else if((temp^(1<<i)) <= r){
            if(((temp|((1<<i)-1)) == l) && (i == 1)){
                cout << l << " " << (temp|(1<<i)) << " " << (temp|((1<<(i+1))-1)) << endl;
            }
            else if(((temp|((1<<i)-1)) == l)){
                cout << l << " " << (temp|(1<<i)) << " " << (temp|(((1<<(i+1))-1)^(1<<(i-1)))) << endl;
            }
            else {
            cout << l << " " << (temp|(1<<i)) << " " << (temp|(1<<i))-1 << endl;
            }
            break;
         }
     }
}
}

#include "bits/stdc++.h"
using namespace std;
#define all(v) v.begin(), v.end()
#define debug(x) cout<< #x<<'='<<x<<endl;
#define ll long long
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;
    while(t--){
     int l,r;
     cin >> l >> r;
     int temp = 0;
     for(int i = 30; i >= 0; i--){
         if(((l>>i)&1))temp^=(1<<i);
         else if((temp^(1<<i)) <= r){
            if(((temp|((1<<i)-1)) == l)){
                cout << l << " " << (temp|(1<<i)) << " " << (temp|((1<<(i))+1)) << endl;
            }
            else {
            cout << l << " " << (temp|(1<<i)) << " " << (temp|(1<<i))-1 << endl;
            }
            break;
         }
     }
}
}

Answer: 2


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll l,r;
        cin>>l>>r;
        ll a,b,c;
        ll ans=0;
        for(int i=30;i>=0;i--){
            ll b1=0;
            ll b2=0;
            if(l & (1ll << i))
                b1=1;
            if(r & (1ll << i))
                b2=1;
            if(b1==b2){
                ans+=b1*(1ll <<i);
            }
            else{
                a=ans+(1ll << i);
                b=a-1;
                break;
            }
        }
        for(ll i=l;i<=r;i++){
            if(i!=a && i!=b){
                c=i;
                break;
            }
        }
        cout << a << " " << b << " " << c << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int reverseBits(int n)
{
    int rev = 0;
    while (n > 0) {
        rev <<= 1;

        if (n & 1 == 1)
            rev ^= 1;
        n >>= 1;
    }

    return rev;
}

int main(){
    int t;
    cin>>t;
    while(t--){
		int a,b;
		cin>>a>>b;
        int c=a+reverseBits(a^b);
        cout<<a<<" "<<b<<" "<<c<<endl;

    }
    return 0;
}

Answer: 1


#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <map>
#include <set>
#include <list>
#include <string>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cassert>
#include <math.h>
#include <iomanip>
#include <limits>

///LLONG_MAX,INT_MA
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;i++)
#define REP(i,n) FOR(i,0,(n)-1)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define sz size()
#define FORA(i,c) REP(i,size(c))

#define itype(c) __typeof((c).begin())
#define FORE(e,c) for(itype(c) e=(c).begin();e!=(c).end();e++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))
#define CLEAR(x,c) memset(x,c,sizeof(x))
#define amfor(Iterator, Container) 	for ( auto Iterator = begin(Container); (Iterator) != end(Container); ++(Iterator) )
#define ramfor(Iterator, Container) for ( auto Iterator = Container.rbegin(); (Iterator) != Container.rend(); ++(Iterator) )
template<class C, class E> inline bool contains(const C& container, const E& element) { return container.find(element) != container.end(); }
#define  NP(nn,ta,a,tb,b) struct nn : pair<ta,tb> { nn():pair<ta,tb>(){}; nn(ta pa,tb pb):pair<ta,tb>(pa,pb){} ta& a(){return first;} tb& b(){return second;} };
template<class T> inline void checkmin(T &a, T b) { if (b < a) a = b; }//asigna en a el minimo
template<class T> inline void checkmax(T &a, T b) { if (b > a) a = b; }//asigna en a el maximo

typedef long long ll;
using namespace std; // since cin and cout are both in namespace std, this saves some text
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int cc;
void Solve()
{
	int l, r;
	cin >> l >> r;
	int mask = 1 << 30;
	while (mask != 0 && (l & mask) ==( r & mask) ) {
		mask >>= 1;
	}
	int a = mask;
	int b = mask - 1;
	int c;
	if (a < r)
		c = a + 1;
	else
		c = b - 1;
	cout << a << " " << b << " " << c;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << std::setprecision(15);
	cout << std::fixed;
	cin >> cc;
	REP(i, cc)
	{
		Solve();
		cout << endl;
	}
	return 0;
}

#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <map>
#include <set>
#include <list>
#include <string>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cassert>
#include <math.h>
#include <iomanip>
#include <limits>

///LLONG_MAX,INT_MA
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;i++)
#define REP(i,n) FOR(i,0,(n)-1)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define sz size()
#define FORA(i,c) REP(i,size(c))

#define itype(c) __typeof((c).begin())
#define FORE(e,c) for(itype(c) e=(c).begin();e!=(c).end();e++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))
#define CLEAR(x,c) memset(x,c,sizeof(x))
#define amfor(Iterator, Container) 	for ( auto Iterator = begin(Container); (Iterator) != end(Container); ++(Iterator) )
#define ramfor(Iterator, Container) for ( auto Iterator = Container.rbegin(); (Iterator) != Container.rend(); ++(Iterator) )
template<class C, class E> inline bool contains(const C& container, const E& element) { return container.find(element) != container.end(); }
#define  NP(nn,ta,a,tb,b) struct nn : pair<ta,tb> { nn():pair<ta,tb>(){}; nn(ta pa,tb pb):pair<ta,tb>(pa,pb){} ta& a(){return first;} tb& b(){return second;} };
template<class T> inline void checkmin(T &a, T b) { if (b < a) a = b; }//asigna en a el minimo
template<class T> inline void checkmax(T &a, T b) { if (b > a) a = b; }//asigna en a el maximo

typedef long long ll;
using namespace std; // since cin and cout are both in namespace std, this saves some text
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int cc;
void Solve()
{
	int l, r;
	cin >> l >> r;
	int mask = 1 << 30;
	int res = 0;
	while (mask != 0 && (l & mask) ==( r & mask) ) {
		mask >>= 1;
		res |= (l & mask);
	}
	int a = mask+res;
	int b = mask - 1+res;
	int c;
	if (a < r)
		c = a + 1;
	else
		c = b - 1;
	cout << a << " " << b << " " << c;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << std::setprecision(15);
	cout << std::fixed;
	cin >> cc;
	REP(i, cc)
	{
		Solve();
		cout << endl;
	}
	return 0;
}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-2;
            c |= mask-1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    cin >> t;
    while (t--) solve();

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

void inline solve() {
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    for (int mask = 1 << 30; mask > 0; mask >>= 1) {
        // cout << "A " << a << ' ' << b << ' ' << c << ' ' << mask << '\n';
        if ((l & mask) == (r & mask)) {
            a |= (l & mask);
            b |= (l & mask);
            c |= (l & mask);
        } else {
            a |= mask;
            b |= mask-1;
            if (b - 1 >= l) c = b-1;
            else c = a + 1;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
    // cout << (a ^ b) + (a ^ c) + (b ^ c) << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    cin >> t;
    while (t--) solve();

    return 0;
}

Answer: 2


#include <bits/stdc++.h>
#ifdef DEBUG
constexpr bool debug = true;
#else
constexpr bool debug = false;
#endif
using namespace std;
using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;

int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    u32 l,r; cin >> l >> r;
    int k = 31 - __builtin_clz(l^r);
    u32 x = l | ((1<<k) - 1);
    u32 y = x + 1;
    u32 z = (x == l ? r : l);
    if constexpr (debug) {
      u32 max = (1 << k+1) -1;
      max <<= 1;
      printf("%u %u | ", max, (x^y)+(y^z)+(x^z));
    }
    printf("%u %u %u\n", x, y, z);
  }
}

#include <bits/stdc++.h>
#ifdef DEBUG
constexpr bool debug = true;
#else
constexpr bool debug = false;
#endif
using namespace std;
using u64 = uint64_t;
using i64 = int64_t;
using u32 = uint32_t;

int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    u32 l,r; cin >> l >> r;
    u32 x = 1 << (31 - __builtin_clz(r));
    u32 y = x - 1;
    u32 z = 0;
    for (auto i = l; i <= r; i++) {
      if (i != x and i != y){
         z = i;
         break;
      }
    }
    if constexpr (debug) {
      u32 max = (1 << (32 - __builtin_clz(r))) -1;
      max <<= 1;
      printf("%u %u | ", max, (x^y)+(y^z)+(x^z));
    }
    printf("%u %u %u\n", x, y, z);
  }
}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = -1;
    for (int i = 0; i <= 30; i++) {
        if ((l^r)>>i & 1) k = i;
    }
    int x = r & (1 << 31 - 1 << k);
    if (r = x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else if (l == x) cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

Answer: 1


#include <bits/stdc++.h>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        ll l, r;
        cin >> l >> r;

        ll ans1 = l;
        ll ans2 = 0;
        ll ans3 = r;
        ll msb = -1;

        for (ll i = 0; i < 60; i++) {
            if ((r & (1LL << i)) != 0) {
                msb = i;
            }
        }

        for (ll i = msb; i >= 0; i--) {
            if ((r & (1LL << i)) != 0 && (l & (1LL << i)) == 0) {
                ll temp = ans2;
                temp = ans2 | (1LL << i);
                if (r == temp) {
                    ans2 = l;
                    for (int j = i - 1; j >= 0; j--) {
                        if ((l & (1LL << j)) == 0) {
                            ans2 = ans2 | (1LL << j);
                        }
                    }
                } else {
                    ans2 = ans2 | (1LL << i);
                    for(int j=i-1;j>=0;j--)
                    {
                      if ((r & (1LL << i)) == 0 && (l & (1LL << i)) == 0)
                      {
                        ans1=ans1|(1LL<<i);
                      }
                    }
                }
                break;
            } else {
                if ((r & (1LL << i)) != 0) {
                    ans2 = (ans2 | (1LL << i));
                }
            }
        }

        cout << ans1 << " " << ans2 << " " << ans3 << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        ll l, r;
        cin >> l >> r;

        ll ans1 = l;
        ll ans2 = 0;
        ll ans3 = r;
        ll msb = -1;

        for (ll i = 0; i < 60; i++) {
            if ((r & (1LL << i)) != 0) {
                msb = i;
            }
        }

        for (ll i = msb; i >= 0; i--) {
            if ((r & (1LL << i)) != 0 && (l & (1LL << i)) == 0) {
                ll temp = ans2;
                temp = ans2 | (1LL << i);
                if (r == temp) {
                    ans2 = l;
                    for (int j = i - 1; j >= 0; j--) {
                        if ((l & (1LL << j)) == 0) {
                            ans2 = ans2 | (1LL << j);
                        }
                    }
                } else {
                    ans2 = ans2 | (1LL << i);
                    for(int j=i-1;j>=0;j--)
                    {
                      if ((r & (1LL << j)) == 0 && (l & (1LL << j)) == 0)
                      {
                        ans1=ans1|(1LL<<j);
                      }
                    }
                }
                break;
            } else {
                if ((r & (1LL << i)) != 0) {
                    ans2 = (ans2 | (1LL << i));
                }
            }
        }

        cout << ans1 << " " << ans2 << " " << ans3 << endl;
    }

    return 0;
}

Answer: 2


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;

    while(num1<=ltemp){
        i--;
        num1+=1<<i;
    }
    int num2 = num1-1;

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }

}

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    for(int i=30; i>ans; i--){
        if((rtemp>>i)&1){
            num1|=(1<<i);
        }
    }
    int num2 = num1-1;

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }

}

Answer: 2


#include <bits/stdc++.h>
#pragma optimzie(2)
#define ll long long
using namespace std;

int l,r;
int main() {
    ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
    int T;cin>>T;
    while(T--){
    	cin>>l>>r;
    	int a,b,c;
		for(int i=30;i>=0;i--){
			int p=1<<i;
			if((l&p)!=(r&p)){
				a=p;b=p-1;break;
			}
		}
		if(a+1<=r){
			c=a+1;
		}
		else{
			c=b-1;
		}
		cout<<a<<' '<<b<<' '<<c<<endl;
	}
    return 0;
}

#include <bits/stdc++.h>
#pragma optimzie(2)
#define ll long long
using namespace std;

int l,r;
int main() {
    ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
    int T;cin>>T;
    while(T--){
    	cin>>l>>r;
    	int a=0,b=0,c=0;
		for(int i=30;i>=0;i--){
			int p=1<<i;
			if((l&p)==(r&p)){
				a+=(l&p);b+=(r&p);
			}
			else{
				a+=p;b+=p-1;break;
			}
		}
		if(a+1<=r){
			c=a+1;
		}
		else{
			c=b-1;
		}
		cout<<a<<' '<<b<<' '<<c<<endl;
	}
    return 0;
}

Answer: 2


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left esquerda
#define lb lower_bound
#define right direita
using namespace std;
void setIO(string s) {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str( ),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9 + 7, MAXN = 2e5 + 5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

void solve() {
    ll l, r;
    cin >> l >> r;

    ll last = 1;
    while(last * 2 <= r)
        last *= 2;

    if(last - 1 >= l && last + 1 <= r) {
        cout << last - 1 << " " << last << " " << last + 1 << endl;
        return;
    }

    if(last == r) {
        cout << l << " " << last - 1 << " " << last << endl;
        return;
    }

    if(last == l) {
        cout << r << " " << r << " " << l << endl;
    }

    ll aux = last;
    for(int i = 30; i >= 0 ; i--)
        if(aux + (1ll << i) <= r && !(r & (1<<i)) ) {
            aux += (1ll <<i);
        }

    if(aux <= l)
        aux = l;

    cout << r << " " << r << " " << aux << endl;
}

int32_t main() {
    int ct;
    cin >> ct;
    while(ct--)
        solve();
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left esquerda
#define lb lower_bound
#define right direita
using namespace std;
void setIO(string s) {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str( ),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9 + 7, MAXN = 2e5 + 5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

void solve() {
    ll l, r;
    cin >> l >> r;

    ll last = 1;
    while(last * 2 <= r)
        last *= 2;

    int aux = last;
    while(true) {
        if( (last & r) && !(last & l)) {
            aux += last;
            break;
        }
        last /= 2;
    }

    cout << aux-1 << " " << aux << " " << aux + 2 << endl;

}

int32_t main() {
    int ct;
    cin >> ct;
    while(ct--)
        solve();
}

Answer: 2