#include<bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define e '\n'
#define pb push_back
#define yes "yes"
#define no "no"
#define F first
#define S second
//#define srt(a) sort(a,a+n)
//#define srt(v) s5ort(v.begin(),v.end())
//#define srt(u) sort(u.begin(),u.end())
#define loop  for(i=1;i<=n;i++)
const int mod=1e9+7;
const int MOD=998244353;
const int lx=1e5+25;
//pair<ll,ll>p[222222];
//map<ll,ll>mp;
//typedef pair<int, int> pi;
//sort(p,p+n,greater<pair<ll,ll>>());-sort vector pair decending order
//priority_queue<pi,vector<pi>,greater<pi>>pq;
//priority_queue<int,vector<int>,greater<int>>pq;-minheap
//priority_queue<pair<int,int>>pq;
//s.erase(position,length)

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

    vector<ll>v, v1, v2, v3;
    for(int i=0; i<=30; i++){
        v.pb(pow(2,i));
    }

    ll a, b, c, n = v.size();
    a = r;
    map<ll,ll>mp;
    for(int i=n-1; i>=0; i--){
        if(a >= v[i]){
            v1.pb(1);
            a-=v[i];
            mp[v[i]]++;
        }
        else
            v1.pb(0);
    }
    b = l, c1=0;
    for(int i=n-1; i>=0; i--){
        if(b >= v[i]){
            v2.pb(1);
            b-=v[i];
            mp[v[i]]++;
        }
        else
            v2.pb(0);
    }
    a = 0, b = 0;
    reverse(v.begin(), v.end());
    for(int i=0; i<v1.size(); i++){
        if(v1[i] == v2[i]){
            if(v1[i] == 1)
                a+=v[i], b+=v[i];
        }
        else{
            a+=v[i], b+=(v[i]-1);
            break;
        }
    }

//    for(int i=0; i<v1.size(); i++)
//        cout<<v1[i]<<" "<<" "<<v2[i]<<e;;

    if(r>a)
        c = a+1;
    else
        c = b-1;

    cout<<a<<" "<<b<<" "<<c<<e;
}

int main(){
    fast()
    int test;
    cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

//        **Number Theory***

//        sort(a+1,a+n+1);
//        long long gcd=a[1];
//        for(int i=2;i<=n;i++){
//             gcd = __gcd(a[i],gcd);
//        }
//         cout<<gcd<<endl;

//        long long s[10];
//        for(i=1;i<10;i++)
//            s[i]=i;
//        s[1]=2;
//        for(i=2;i<10;i++){
//            q=s[i]*s[i-1];
//            long long gcd = __gcd(s[i],s[i-1]);
//            s[i]=q/gcd;//   -LCM
//        }
//        for(i=1;i<10;i++)
//            cout<<s[i]<<" ";
//        *Linear Diophantine Equations
//        1.ax+by=c
//        there will be a solution if gcd(a,b) can divide c

//        convert string to int and int to string
//        string t;
//        cin>>n;
//        p=stoi(t);
//        std:: string s = std::to_string(n);
//        cout<<s;
//        build all permutation of a string
//        string s="1234";
//        do {
//            std::cout<<s<<std::endl;
//        } while (std::next_permutation(s.begin(),s.end()));

//    Harmonic series-nlogn
//    for(i=1;i<=n;i++){
//        for(j=i;j<=n;j+=i)
//            operation.....
//    }

#include<bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define e '\n'
#define pb push_back
#define yes "yes"
#define no "no"
#define F first
#define S second
//#define srt(a) sort(a,a+n)
//#define srt(v) s5ort(v.begin(),v.end())
//#define srt(u) sort(u.begin(),u.end())
#define loop  for(i=1;i<=n;i++)
const int mod=1e9+7;
const int MOD=998244353;
const int lx=1e5+25;
//pair<ll,ll>p[222222];
//map<ll,ll>mp;
//typedef pair<int, int> pi;
//sort(p,p+n,greater<pair<ll,ll>>());-sort vector pair decending order
//priority_queue<pi,vector<pi>,greater<pi>>pq;
//priority_queue<int,vector<int>,greater<int>>pq;-minheap
//priority_queue<pair<int,int>>pq;
//s.erase(position,length)

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

    vector<ll>v, v1, v2, v3;
    for(int i=0; i<=30; i++){
        v.pb(pow(2,i));
    }

    //reverse(v.begin(), v.end());
    ll a, b, c, n = v.size();
    a = r;
    map<ll,ll>mp;
    for(int i=n-1; i>=0; i--){
        if(a >= v[i]){
            v1.pb(1);
            a-=v[i];
            mp[v[i]]++;
            c1++;
        }
        else if(c1>0)
            v1.pb(0);
    }
    b = l, c1=0;
    for(int i=n-1; i>=0; i--){
        if(b >= v[i]){
            v2.pb(1);
            b-=v[i];
            mp[v[i]]++;
            c1++;
        }
        else if(c1>0)
            v2.pb(0);
    }

    ll x = l+1, y = r-1;
    c1=0, c=0;
    for(int i=n-1; i>=0; i--){
        if(mp[v[i]] == 0){
            if(v[i]>=x && v[i]<=y){
                x-=v[i], y-=v[i];
                v3.pb(1);
                c+=v[i];
            }
            else
                v3.pb(0);

        }
        else if(mp[v[i]]>0){
            ll sum=0;
            for(int j=i-1; j>=0; j--)
                sum+=v[j];
            if(sum>=x && sum<=y)
                v3.pb(0);
            else{
                if(v[i]<=x && v[i]<=y){
                    x-=v[i], y-=v[i];
                    v3.pb(1);
                    c+=v[i];
                }
                else
                    v3.pb(0);
            }
        }

        //cout<<x<<" "<<y<<e;
    }

//    for(int i=0; i<v3.size(); i++)
//        cout<<v3[i]<<" ";
//    cout<<e;
    cout<<l<<" "<<c<<" "<<r<<e;
}

int main(){
    fast()
    int test;
    cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

//        **Number Theory***

//        sort(a+1,a+n+1);
//        long long gcd=a[1];
//        for(int i=2;i<=n;i++){
//             gcd = __gcd(a[i],gcd);
//        }
//         cout<<gcd<<endl;

//        long long s[10];
//        for(i=1;i<10;i++)
//            s[i]=i;
//        s[1]=2;
//        for(i=2;i<10;i++){
//            q=s[i]*s[i-1];
//            long long gcd = __gcd(s[i],s[i-1]);
//            s[i]=q/gcd;//   -LCM
//        }
//        for(i=1;i<10;i++)
//            cout<<s[i]<<" ";
//        *Linear Diophantine Equations
//        1.ax+by=c
//        there will be a solution if gcd(a,b) can divide c

//        convert string to int and int to string
//        string t;
//        cin>>n;
//        p=stoi(t);
//        std:: string s = std::to_string(n);
//        cout<<s;
//        build all permutation of a string
//        string s="1234";
//        do {
//            std::cout<<s<<std::endl;
//        } while (std::next_permutation(s.begin(),s.end()));

//    Harmonic series-nlogn
//    for(i=1;i<=n;i++){
//        for(j=i;j<=n;j+=i)
//            operation.....
//    }

Answer: 1


#include<bits/stdc++.h>
using namespace std;
#define int long long
int t,l,r;
void work()
{
    for(int w = (1ll << 30);w >= 1;w >>= 1)
        if((l & w) != (r & w)) {
            int x = r / w * w;
            cout<<x<<" "<<x - 1<<" "<<(r == x ? l : r)<<endl;
            return;
        }
}
signed main()
{
    ios::sync_with_stdio(false);

    cin>>t;
    while(t--) cin>>l>>r,work();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
int t,l,r;
void work()
{
    for(int w = (1ll << 30);w >= 1;w >>= 1)
        if((l & w) != (r & w)) {
            int x = r / w * w;
            cout<<x<<" "<<x - 1<<" "<<(r == x ? x - 1 : x)<<endl;
            return;
        }
}
signed main()
{
    ios::sync_with_stdio(false);

    cin>>t;
    while(t--) cin>>l>>r,work();

    return 0;
}

Answer: 1


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<functional>
using namespace std;

//#define int long long
#define ll long long
#define PA pair<ll,ll>
#define MAXN 100100

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

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

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

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<functional>
using namespace std;

//#define int long long
#define ll long long
#define PA pair<ll,ll>
#define MAXN 100100

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

	function<bool(ll)>check = [&](ll num)->bool {
		return num >= l && num <= r;
	};

	bool w = false;
	for (int i = 30; i >= 0; i--) {
		if ((l & (1 << i)) != (r & (1 << i))) {

		}
		else {
			if(check(b^(1<<i)))
				b = b ^ (1 << i);
		}
	}

	cout << l << " " << b << " " << r << endl;
}

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

Answer: 1


// by iodwad
#include <bits/stdc++.h>

using namespace std;

void Solve() {
  int l, r, k; cin >> l >> r;
  for (int i = 30; ~i; --i) {
    if ((l ^ r) & (1 << i)) {
      k = i;
      break;
    }
  }
  int a, b, c;
  int tmp = (l >> k + 1) << k + 1;
  a = (1 << k) - 1 + tmp; b = a + 1; c = l;
  if (a == c) c = r;
  printf("%d %d %d\n", a, b, c);
}

int main() {
  int cases; cin >> cases;
  while (cases--) {
    Solve();
  }
  return 0;
}
/

Answer: 1


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

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

    // Find the highest bit where l and r differ.
    // __builtin_clz(x) gives the number of leading zeros in x,
    // so 31 - __builtin_clz(l ^ r) is the position of that highest differing bit (0-based).
    int k = 31 - __builtin_clz(l ^ r);

    // Construct a by setting all bits below k to 1 in l.
    int a = l | ((1 << k) - 1);

    // Then b is just a+1, and c is the opposite endpoint if a == l, else c = l.
    int b = a + 1;
    int c = (a == l ? r : l);

    // If b > r (edge case), simply pick the top three distinct values near r.
    // This handles the case where a+1 might exceed r.
    if (b > r) {
        a = r - 2;
        b = r - 1;
        c = r;
    }

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

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

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

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

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

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

        // Gather at most the last 8 numbers in [l, r].
        long long start = max(l, r - 7);
        vector<long long> cand;
        for (long long x = start; x <= r; x++) {
            cand.push_back(x);
        }

        // Brute force all distinct triples among these candidates.
        long long bestVal = -1;
        array<long long,3> bestTriple = {l, l+1, l+2}; // just a valid placeholder
        int sz = (int)cand.size();
        for (int i = 0; i < sz; i++) {
            for (int j = i + 1; j < sz; j++) {
                for (int k = j + 1; k < sz; k++) {
                    long long a = cand[i], b = cand[j], c = cand[k];
                    long long val = (a ^ b) + (b ^ c) + (a ^ c);
                    if (val > bestVal) {
                        bestVal = val;
                        bestTriple = {a, b, c};
                    }
                }
            }
        }

        // Output any triple that maximizes the expression.
        cout << bestTriple[0] << " "
             << bestTriple[1] << " "
             << bestTriple[2] << "\n";
    }
    return 0;
}

Answer: 1


#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

void solve() {
    ll l,r;
    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";
}

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

#include<bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
#define ll long long
#define mp make_pair
#define yes cout << "YES" << "\n"
#define no cout << "NO" << "\n"

string decimalToBinary(ll decimal_number){
    bitset<64> binary(decimal_number);
    return binary.to_string();
}

ll binaryToDecimal(string &binary_string){
    bitset<64> binary(binary_string);
    return binary.to_ullong();
}

void solve() {
    ll l,r;
    cin>>l>>r;
    string a,b;
    a = decimalToBinary(l);
    b = decimalToBinary(r);
    ll x,y,z;
    for(ll i=0; i<a.size(); i++){
        if(a[i]!=b[i]) {
            x=i;
        }
    }
    for(ll i=x+1; i<a.size(); i++) b[i]='0';
    x = binaryToDecimal(b);
    y = x-1;
    z = x-2;
    if(z<l) z= x+1;
    cout<<x<<" "<<y<<" "<<z<<endl;
}

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

Answer: 1


#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t * -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
	while(t != lowbit(t))
		t -= lowbit(t);
	t |= l;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

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

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define endl '\n'
#define INT __int128
#define N 100010

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned int;

int lowbit(int t)
{
	return t & -t;
}

void sol()
{
	int l, r;
	cin >> l >> r;
	int t = l ^ r;
//	cout << t << endl;
	while(t != lowbit(t))
		t -= lowbit(t);
//	cout << t << endl;
	t = (l / t * t) | t;
//	cout << t << endl;
	int a, b, c;
	a = t, b = t - 1, c = r;
	while(c == a || c == b)	c --;
	cout << a << ' ' << b << ' ' << c << endl;
}

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

Answer: 2


#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using i8 = int8_t;
using u8 = uint8_t;
using ish = int16_t;
using ush = uint16_t;

const ll MOD = 1e9 + 7;
const ll OMOD = 998'244'353;

inline namespace IO {
#define SFINAE(x, ...)                                                                                \
    template <class, class = void> struct x : std::false_type {};                                            \
    template <class T> struct x<T, std::void_t<__VA_ARGS__>> : std::true_type {}

SFINAE(DefaultI, decltype(std::cin >> std::declval<T &>()));
SFINAE(DefaultO, decltype(std::cout << std::declval<T &>()));
SFINAE(IsTuple, typename std::tuple_size<T>::type);
SFINAE(Iterable, decltype(std::begin(std::declval<T>())));

template <auto &is> struct Reader {
    template <class T> void Impl(T &t) {
        if constexpr (DefaultI<T>::value)
            is >> t;
        else if constexpr (Iterable<T>::value) {
            for (auto &x : t)
                Impl(x);
        } else if constexpr (IsTuple<T>::value) {
            std::apply([this](auto &...args) { (Impl(args), ...); }, t);
        } else
            static_assert(IsTuple<T>::value, "No matching type for read");
    }
    template <class... Ts> void read(Ts &...ts) { ((Impl(ts)), ...); }
};

template <class... Ts> void re(Ts &...ts) { Reader<cin>{}.read(ts...); }
#define def(t, args...)                                                                                \
    t args;                                                                                \
    re(args);

template <auto &os, bool debug, bool print_nd> struct Writer {
    string comma() const { return debug ? "," : ""; }
    template <class T> constexpr char Space(const T &) const {
        return print_nd && (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' ';
    }
    template <class T> void Impl(T const &t) const {
        if constexpr (DefaultO<T>::value)
            os << t;
        else if constexpr (Iterable<T>::value) {
            if (debug)
                os << '{';
            int i = 0;
            for (auto &&x : t)
                ((i++) ? (os << comma() << Space(x), Impl(x)) : Impl(x));
            if (debug)
                os << '}';
        } else if constexpr (IsTuple<T>::value) {
            if (debug)
                os << '(';
            std::apply(
                [this](auto const &...args) {
                    int i = 0;
                    (((i++) ? (os << comma() << " ", Impl(args)) : Impl(args)), ...);
                },
                t);
            if (debug)
                os << ')';
        } else
            static_assert(IsTuple<T>::value, "No matching type for print");
    }
    template <class T> void ImplWrapper(T const &t) const {
        if (debug)
            os << "\033[0;31m";
        Impl(t);
        if (debug)
            os << "\033[0m";
    }
    template <class... Ts> void print(Ts const &...ts) const { ((Impl(ts)), ...); }
    template <class F, class... Ts>
    void print_with_sep(const std::string &sep, F const &f, Ts const &...ts) const {
        ImplWrapper(f), ((os << sep, ImplWrapper(ts)), ...), os << '\n';
    }
    void print_with_sep(const std::string &) const { os << '\n'; }
};

template <class... Ts> void pr(Ts const &...ts) { Writer<cout, false, true>{}.print(ts...); }
template <class... Ts> void ps(Ts const &...ts) { Writer<cout, false, true>{}.print_with_sep(" ", ts...); }
} // namespace IO

inline namespace Debug {
template <typename... Args> void err(Args... args) {
    Writer<cerr, true, false>{}.print_with_sep(" | ", args...);
}
template <typename... Args> void errn(Args... args) {
    Writer<cerr, true, true>{}.print_with_sep(" | ", args...);
}

void err_prefix(string func, int line, string args) {
    cerr << "\033[0;31m\u001b[1mDEBUG\033[0m"
         << " | "
         << "\u001b[34m" << func << "\033[0m"
         << ":"
         << "\u001b[34m" << line << "\033[0m"
         << " - "
         << "[" << args << "] = ";
}

#ifdef LOCAL
#define clg(args...) err_prefix(__FUNCTION__, __LINE__, #args), err(args)
#else
#define clg(...)
#endif

} // namespace Debug

void solve() {
    int L, r;
    cin >> L >> r;
    string h = bitset<32>(r).to_string();
    string l = bitset<32>(L).to_string();
    char ans[33];
    ans[32] = '\0';
    bool f = true;
    bool f2 = true;
    bool f3 = false;
    for (int i = 0; i < 32; ++i) {
        if (f) {
            if (h[i] == l[i]) {
                ans[i] = h[i];
            } else {
                f = false;
                --i;
            }
        } else {
            if (f2) {
                if ((h[i + 1] == l[i + 1] && h[i + 1] == '1') || (h[i + 1] == '1' && l[i + 1] == '0')) {
                    ans[i] = '1';
                    ans[i + 1] = '0';
                    ++i;
                    f3 = true;
                    f2 = false;
                    continue;
                } else if (h[i + 1] == l[i + 1] && h[i + 1] == '0') {
                    ans[i] = '0';
                    ans[i + 1] = '1';
                    ++i;
                    f3 = true;
                    f2 = false;
                    continue;
                } else {
                    bool isallzero = true;
                    for (int j = i + 1; j < 32; ++j) {
                        if (h[j] == '0') {
                        } else {
                            isallzero = false;
                            break;
                        }
                    }
                    if (isallzero) {
                        ans[i] = '0';
                        for (int j = i + 1; j < 32; ++j) {
                            ans[j] = '1';
                        }
                        pr(L, " ");
                        pr(stol(ans, nullptr, 2));
                        pr(" ", r);
                        ps();
                        return;
                    } else {
                        ans[i] = '1';
                        for (int j = i + 1; j < 32; ++j) {
                            ans[j] = '0';
                        }
                        for (int j = i + 1; j < 32; ++j) {
                            l[j] = '1';
                        }
                        ps(stol(h, nullptr, 2), stol(ans, nullptr, 2), stol(l, nullptr, 2));
                        return;
                    }
                }
            }
            if (f3) {
                if (h[i] == l[i] && h[i] == '1') {
                    ans[i] = '0';
                } else {
                    ans[i] = '1';
                }
            }
        }
    }
    ps(L, stol(ans, nullptr, 2), r);
}

int main() {
#if defined(LOCAL)
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#include <bits/stdc++.h>
using namespace std;

using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using i8 = int8_t;
using u8 = uint8_t;
using ish = int16_t;
using ush = uint16_t;

const ll MOD = 1e9 + 7;
const ll OMOD = 998'244'353;

inline namespace IO {
#define SFINAE(x, ...)                                                                                \
    template <class, class = void> struct x : std::false_type {};                                            \
    template <class T> struct x<T, std::void_t<__VA_ARGS__>> : std::true_type {}

SFINAE(DefaultI, decltype(std::cin >> std::declval<T &>()));
SFINAE(DefaultO, decltype(std::cout << std::declval<T &>()));
SFINAE(IsTuple, typename std::tuple_size<T>::type);
SFINAE(Iterable, decltype(std::begin(std::declval<T>())));

template <auto &is> struct Reader {
    template <class T> void Impl(T &t) {
        if constexpr (DefaultI<T>::value)
            is >> t;
        else if constexpr (Iterable<T>::value) {
            for (auto &x : t)
                Impl(x);
        } else if constexpr (IsTuple<T>::value) {
            std::apply([this](auto &...args) { (Impl(args), ...); }, t);
        } else
            static_assert(IsTuple<T>::value, "No matching type for read");
    }
    template <class... Ts> void read(Ts &...ts) { ((Impl(ts)), ...); }
};

template <class... Ts> void re(Ts &...ts) { Reader<cin>{}.read(ts...); }
#define def(t, args...)                                                                                \
    t args;                                                                                \
    re(args);

template <auto &os, bool debug, bool print_nd> struct Writer {
    string comma() const { return debug ? "," : ""; }
    template <class T> constexpr char Space(const T &) const {
        return print_nd && (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' ';
    }
    template <class T> void Impl(T const &t) const {
        if constexpr (DefaultO<T>::value)
            os << t;
        else if constexpr (Iterable<T>::value) {
            if (debug)
                os << '{';
            int i = 0;
            for (auto &&x : t)
                ((i++) ? (os << comma() << Space(x), Impl(x)) : Impl(x));
            if (debug)
                os << '}';
        } else if constexpr (IsTuple<T>::value) {
            if (debug)
                os << '(';
            std::apply(
                [this](auto const &...args) {
                    int i = 0;
                    (((i++) ? (os << comma() << " ", Impl(args)) : Impl(args)), ...);
                },
                t);
            if (debug)
                os << ')';
        } else
            static_assert(IsTuple<T>::value, "No matching type for print");
    }
    template <class T> void ImplWrapper(T const &t) const {
        if (debug)
            os << "\033[0;31m";
        Impl(t);
        if (debug)
            os << "\033[0m";
    }
    template <class... Ts> void print(Ts const &...ts) const { ((Impl(ts)), ...); }
    template <class F, class... Ts>
    void print_with_sep(const std::string &sep, F const &f, Ts const &...ts) const {
        ImplWrapper(f), ((os << sep, ImplWrapper(ts)), ...), os << '\n';
    }
    void print_with_sep(const std::string &) const { os << '\n'; }
};

template <class... Ts> void pr(Ts const &...ts) { Writer<cout, false, true>{}.print(ts...); }
template <class... Ts> void ps(Ts const &...ts) { Writer<cout, false, true>{}.print_with_sep(" ", ts...); }
} // namespace IO

inline namespace Debug {
template <typename... Args> void err(Args... args) {
    Writer<cerr, true, false>{}.print_with_sep(" | ", args...);
}
template <typename... Args> void errn(Args... args) {
    Writer<cerr, true, true>{}.print_with_sep(" | ", args...);
}

void err_prefix(string func, int line, string args) {
    cerr << "\033[0;31m\u001b[1mDEBUG\033[0m"
         << " | "
         << "\u001b[34m" << func << "\033[0m"
         << ":"
         << "\u001b[34m" << line << "\033[0m"
         << " - "
         << "[" << args << "] = ";
}

#ifdef LOCAL
#define clg(args...) err_prefix(__FUNCTION__, __LINE__, #args), err(args)
#else
#define clg(...)
#endif

} // namespace Debug

void solve() {
    int L, r;
    cin >> L >> r;
    string h = bitset<32>(r).to_string();
    string l = bitset<32>(L).to_string();
    char ans[32];
    bool f = true;
    bool f2 = true;
    bool f3 = false;
    for (int i = 0; i < 32; ++i) {
        if (f) {
            if (h[i] == l[i]) {
                ans[i] = h[i];
            }
        } else {
            f = false;
            if (f2) {
                if ((h[i + 1] == l[i + 1] && h[i + 1] == '1') || (h[i + 1] == '1' && l[i + 1] == '0')) {
                    ans[i] = '1';
                    ans[i + 1] = '0';
                    ++i;
                    f3 = true;
                    f2 = false;
                } else if (h[i + 1] == l[i + 1] && h[i + 1] == '0') {
                    ans[i] = '1';
                    ans[i + 1] = '0';
                    ++i;
                    f3 = true;
                    f2 = false;
                } else {
                    bool isallzero = true;
                    for (int j = i + 1; j < 32; ++j) {
                        if (h[j] == '0') {
                        } else {
                            isallzero = false;
                            break;
                        }
                    }
                    if (isallzero) {
                        ans[i] = '0';
                        for (int j = i + 1; j < 32; ++j) {
                            ans[i] = '1';
                        }
                        pr(l, " ");
                        pr(stol(ans, nullptr, 2));
                        pr(" ", r);
                        ps();
                        return;
                    } else {
                        ans[i] = '1';
                        for (int j = i + 1; j < 32; ++j) {
                            ans[i] = '0';
                        }
                        for (int j = i + 1; j < 32; ++j) {
                            l[i] = '1';
                        }
                        ps(stol(h, nullptr, 2), stol(ans, nullptr, 2), stol(l, nullptr, 2));
                        return;
                    }
                }
            }
            if (f3) {
                if (h[i] == l[i] && h[i] == '1') {
                    ans[i] = '0';
                } else {
                    ans[i] = '1';
                }
            }
        }
    }
    ps(L, stol(ans, nullptr, 2), r);
}

int main() {
#if defined(LOCAL)
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc = 1;
    cin >> tc;
    while (tc--) {
        solve();
    }
    return 0;
}

Answer: 1


// Problem: C. Trip to the Olympiad
// Contest: Codeforces - Hello 2025
// URL: https://codeforces.com/contest/2057/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define int long long
#define inf 2e18
#define ull unsigned long long
#define ls o << 1
#define rs o << 1 | 1

using namespace std;

const int N = 2e5 + 9;

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

	int suml = 0, sumr = 0;

	int tmp = l;
	while(tmp) {
		suml ++;
		tmp >>= 1;
	}

	tmp = r;
	while(tmp) {
		sumr ++;
		tmp >>= 1;
	}

	int a = 0, b = 0, c = 0;
	if(sumr > suml) {
		a = 1ll << (sumr - 1);
		b = a - 1;
		c = l;
		while(c == a || c == b)c ++;
	} else {
		int idx;
		for(idx = sumr;idx >= 1;idx --) {
			a = (a | (1ll << (idx - 1)));
			if((r & (1ll << (idx - 1))) != (l & (1ll << (idx - 1))))
				break;
		}

		a = (a | (1ll << (idx - 1)));
		b = a - 1;
		c = l;
		while(c == a || c == b)c ++;
	}

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

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

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

    return 0;
}

/*
What you want is what you love, so fight for it!
*/

// Problem: C. Trip to the Olympiad
// Contest: Codeforces - Hello 2025
// URL: https://codeforces.com/contest/2057/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define int long long
#define inf 2e18
#define ull unsigned long long
#define ls o << 1
#define rs o << 1 | 1

using namespace std;

const int N = 2e5 + 9;

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

	int suml = 0, sumr = 0;

	int tmp = l;
	while(tmp) {
		suml ++;
		tmp >>= 1;
	}

	tmp = r;
	while(tmp) {
		sumr ++;
		tmp >>= 1;
	}

	int a = 0, b = 0, c = 0;
	if(sumr > suml) {
		a = 1ll << (sumr - 1);
		b = a - 1;
		c = l;
		while(c == a || c == b)c ++;
	} else {
		int idx;
		for(idx = sumr;idx >= 1;idx --) {
			a = (a | (r & (1ll << (idx - 1))));
			if((r & (1ll << (idx - 1))) != (l & (1ll << (idx - 1))))
				break;
		}

		a = (a | (1ll << (idx - 1)));
		b = a - 1;
		c = l;
		while(c == a || c == b)c ++;
	}

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

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

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

    return 0;
}

/*
What you want is what you love, so fight for it!
*/

Answer: 2


#include <bits/stdc++.h>
#define int long long
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
#define bugv(VEC)               \
    {                           \
        for (auto Vec : VEC)    \
            cout << Vec << ' '; \
        cout << '\n';           \
    }

void _();
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    int T = 1;
    cin >> T;
    while (T--)
        _();
    return 0;
}

void _()
{
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    int hi = 32;
    for (;; hi--)
    {
        int r_bit = r >> hi & 1, l_bit = l >> hi & 1;
        if (r_bit - l_bit)
            break;
        else if (l_bit)
        {
            a |= 1 << hi, b |= 1 << hi, c |= 1 << hi;
        }
    }
    c |= 1 << hi;
    b = c - 1;
    a = b - 1 < l ? c + 1 : b - 1;
    cout << a << ' ' << b << ' ' << c << '\n';
}
// void _()
// {
//     int a, b, c;
//     cin >> a >> b >> c;
//     cout << (a ^ b) + (b ^ c) + (a ^ c) << '\n';
// }

#include <bits/stdc++.h>
#define int long long
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
#define bugv(VEC)               \
    {                           \
        for (auto Vec : VEC)    \
            cout << Vec << ' '; \
        cout << '\n';           \
    }

void _();
signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    int T = 1;
    cin >> T;
    while (T--)
        _();
    return 0;
}

void _()
{
    int l, r;
    cin >> l >> r;
    int a = 0, b = 0, c = 0;
    int hi = 32;
    for (;; hi--)
    {
        int r_bit = r >> hi & 1, l_bit = l >> hi & 1;
        if (r_bit - l_bit)
            break;
        else if (l_bit)
        {
            a |= 1 << hi, b |= 1 << hi, c |= 1 << hi;
        }
    }
    c |= 1 << hi;
    b = c - 1;
    a = b - 1;
    cout << a << ' ' << b << ' ' << c << '\n';
}
// void _()
// {
//     int a, b, c;
//     cin >> a >> b >> c;
//     cout << (a ^ b) + (b ^ c) + (a ^ c) << '\n';
// }

Answer: 1


// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    ll base = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
        base |= (gbit(l, k) << k);
    }
    ll a = (1 << now), b = a - 1;
    a |= base, b |= base;
    ll c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

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

// #define ONLINE_JUDGE 1
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>;
#define all(a) (a).begin(),(a).end()
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
const ll N = 2e6 + 10;
#ifdef ONLINE_JUDGE
#define dbg(x)
#else
#define dbg(x) cerr << #x << "==" << (x) << '\n' << flush;
#endif
template<class... T> void input(T &...a) { (cin >> ... >> a); }
template<class T,class U> bool chmax(T &a, const U b) {return a<b?a=b,true:false; }
template<class T,class U> bool chmin(T &a, const U b) {return a>b?a=b,true:false; }
// clang-format on
bool gbit(ll n, ll k) { return (n >> k) & 1; }
void solve()
{
    LL(l, r);
    vector<ll> ans(3);
    ll now = 0;
    for (ll k = 30; k >= 0; k--)
    {
        if (gbit(l, k) != gbit(r, k))
        {
            now = k;
            break;
        }
    }
    ll a = (1 << now), b = a - 1, c = (b - 1 >= l ? b - 1 : a + 1);
    cout << a << ' ' << b << ' ' << c << '\n';
}

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

Answer: 1


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

int32_t main()
{
    int t;
    cin>>t;
    while(t--){
      int l,r;
      cin>>l>>r;
      if(r-l==2){
        cout<<l<<" "<<l+1<<" "<<r<<endl;
        continue;
      }
      int val=pow(2,30);
      int ans=-1;
      while(ans==-1){
        int x=l/val;
        int y=r/val;
        if(x==y){
          if(y-x+1>val){
          int a=(x+1)*val;
            if(a-2>=l){
              cout<<a<<" "<<a-1<<" "<<a-2;
            }
            else{
              cout<<a<<" "<<a-1<<" "<<a+1;
            }
            break;
          }
        }
        else{
         int a=(x+1)*val;
            if(a-2>=l){
              cout<<a<<" "<<a-1<<" "<<a-2;
            }
            else{
              cout<<a<<" "<<a-1<<" "<<a+1;
            }
            break;
        }
        val=val/2;
      }
      cout<<endl;

    }
}

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

int32_t main()
{
    int t;
    cin>>t;
    while(t--){
      int l,r;
      cin>>l>>r;
      if(r-l==2){
        cout<<l<<" "<<l+1<<" "<<r<<endl;
        continue;
      }
      int val=pow(2,30);
      int ans=-1;
      while(ans==-1){
        int x=l/val;
        int y=r/val;
        if(x==y){
          if(y-x+1>val){
          int a=(x+1)*val;
            if(a-2>=l){
              cout<<a<<" "<<a-1<<" "<<a-2;
            }
            else{
              cout<<a<<" "<<a-1<<" "<<a+1;
            }
            break;
          }
        }
        else{
         int a=(x+1)*val;
            if(a-2>=l){
              cout<<a<<" "<<a-1<<" "<<a-2;
            }
            else{
              cout<<a<<" "<<a-1<<" "<<a+1;
            }
            break;
        }
        val=val/2;
      }

    }
}

Answer: 1


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace chrono;

using namespace __gnu_pbds;

template<typename T>
using orderedSet = tree<T , null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using orderedMultiset = tree<T , null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) -> iterator at k
// order_of_key(k) -> number of items that are strictly smaller than k

#define FASTIO() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD1 1000000007
#define MOD9 998244353
#define INF 1e9
#define INF1 1e18
#define endl "\n"
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
#define ub upper_bound
#define fcout cout<<fixed<<setprecision(10)
#define YES  cout<<"YES"<<endl
#define NO cout<<"NO"<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

// ---------------------------------- DEFINES ---------------------------------------
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vector <int> > vvi;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T, vector<T>, greater<T>>;
// ----------------------------------------------------------------------------------

// ---------------------------------- OPERATOR OVERLOADING ---------------------------------------
template<typename T>
istream& operator>>(istream &istream, vector<T> &v) {for (auto &x : v)cin >> x; return istream;}
template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &v) { for (auto &x : v) cout << x << " "; return ostream; }
template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.ff >> p.ss); }
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.ff << " " << p.ss); }
template<typename T1, typename T2>
istream& operator>>(istream &istream, vector<pair<T1, T2>> &v) {for (auto &x : v)cin >> x; return istream;}
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, const vector<pair<T1, T2>> &v) { for (auto &x : v) cout << x << endl; return ostream; }
template<typename T>
istream& operator>>(istream &istream, vector<vector<T>> &v) {for (auto &x : v)cin >> x; return istream;}
template<typename T>
ostream& operator<<(ostream &ostream, const vector<vector<T>> &v) { for (auto &x : v) cout << x << endl; return ostream; }
// ------------------------------------------------------------------------------------------------

// ------------------------------------------ DEBUG ------------------------------------------------
#ifndef ONLINE_JUDGE
#define debug(x...) cerr <<__func__<<":"<<__LINE__<<" [" << #x << "] = "; _print(x); cerr << endl;
#define HERE cerr <<__func__<<":"<<__LINE__<<" [ here ] "; 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) {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 << "]";}
template <class T> void _print(vector <vector <T> > v) {cerr << "{ "; for (vector<T> i : v) {cerr << "[ "; for (T j : i) {_print(j); cerr << " ";}; cerr << "] ";} cerr << "}";}
template <class T, class V> void _print(vector < pair <T , V> > vp) {cerr << "{ "; for (pair<T, V> i : vp) {cerr << "[ "; "{"; _print(i.ff); cerr << ","; _print(i.ss); cerr << " ] ";} cerr << "}";}
template <class T> void _print(stack <T> st) {cerr << "[ "; while (!st.empty()) {_print(st.top()); st.pop(); cerr << " ";} cerr << "]";}
template <class T> void _print(queue <T> q) {cerr << "[ "; while (!q.empty()) {_print(q.front()); q.pop(); cerr << " ";} cerr << "]";}
template <class T> void _print(deque <T> dq) {cerr << "[ "; while (!dq.empty()) {_print(dq.front()); dq.pop_front(); cerr << " ";} cerr << "]";}
template <class T> void _print(PQ <T> pq) {cerr << "[ "; while (!pq.empty()) {_print(pq.top()); pq.pop(); cerr << " ";} cerr << "]";}
template <class T> void _print(QP <T> pq) {cerr << "[ "; while (!pq.empty()) {_print(pq.top()); pq.pop(); cerr << " ";} cerr << "]";}
//---------------------------------------------------------------------------------------------------

void solve() {

    //solution starts from here
    ll l, r;
    cin >> l >> r;
    int mx = 0;
    for (int i = 0; i < 32; i++) {
            if ((r & (1LL << i)) && (l & (1LL << i)) == 0) mx = i;
    }
    int a = 0;
    for (int i = mx; i < 32; i++) {
            a |= ((1LL << i) & r);
    }
    if (r >= a + 1) {
            cout << a << " " << a + 1 << " " << a - 1 << endl;
            debug((a^(a+1)) + ((a+1)^(a-1)) + ((a-1)^a))
    }
    else {
        cout << a << " " << a - 1 << " " << a - 2 << endl;
        debug((a^(a-1)) + ((a-1)^(a-2)) +((a-2)^(a)))

    }
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif

    FASTIO();
    auto start1 = high_resolution_clock::now();
    int t = 1;
    cin >> t;
    int T = t;
    while (t--)
    {
       #ifndef ONLINE_JUDGE
        cerr<<"Test "<<(T-t)<<" :"<<endl;
       #endif
       solve();
       #ifndef ONLINE_JUDGE
        cerr<<"--------------------------"<<endl<<endl;
       #endif
    }
    auto stop1 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed : " << (duration . count() / 1000000) << '.' << (duration . count() % 1000000) << endl;
#endif

}

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int test = sc.nextInt();
		for (int z = 0; z < test; z++) {

			long l = sc.nextInt();
			long r = sc.nextInt();
			long one = l;
			long two;
			long three;
			long i =1;
			if((r-l+1)==3) {
				two=l+1;
				three=l+2;
			} else {
				while (i<=r) {
					i=i*2;
				}
				if(i/2<=l){
				    if((r-l+1) >=6 ){
				        two= r-3;
				        three=r;

				    }else{
				        two= r-1;
				        three= r;
				        one = r-2;
				    }

				}
				else{
				    three=i/2;
				    two=three-1;
				}

			}

			System.out.println(one+" "+two+" "+three);

		}
	}
}

Answer: 2


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	int res=0;
	while(1){
		if(r-l==2){
			cout<<l+res<<" "<<l+res+1<<" "<<l+res+2<<"\n";
			return;
		}
		int x=1;
		while(x*2<=r)x<<=1;
		if(x<=l){
			res+=x;
			l-=x;
			r-=x;
			continue;
		}
		cout<<x+res<<" "<<x+res-1<<" "<<(x==r?l:r)+res<<"\n";
		break;
	}
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int l,r;
int a[3];
void solve(){
	memset(a,0,sizeof(a));
	cin>>l>>r;
	for(int i=30;i>=0;i--){
		sort(a,a+3);
		int x=1<<i;
		if(a[0]+x>r)continue;
		if(a[2]+x<=l){
			a[0]+=x;
			a[1]+=x;
			a[2]+=x;
			continue;
		}
		a[0]+=x;
		if(a[1]<l&&l<=a[1]+x&&a[1]+x<=r)a[1]+=x;
	}
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
	return;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	while(T--)solve();
	return 0;
}

Answer: 1


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 //find_by order()->iterator of indexed element,  order_of_key()-> number of elements strictly less than x
#define lli long long int
typedef tree < lli,  null_type ,  less_equal<lli> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

#define endl '\n'
using pii=pair<lli,lli>;
#define MP make_pair
#define F first
#define ld long double
#define S second
#define all(o) o.begin(),o.end()
lli M=1e9+7;
using mll = map<lli,lli>;
using vi = vector<lli>;
using vvi = vector<vector<lli>>;
using vpii = vector<pii>;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mem(a,b) memset(a,b,sizeof(a))
#define state pair<lli,pii>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x) cout << #x << "=" << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define pb push_back
#define mid (l+r)/2
#define lb lower_bound
#define ub upper_bound
template <typename T> T gcd(T a, T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T bin_pow(T b, T p, T m){T x = 1;while(p){if(p&1)x=(x*b)%m;b=(b*b)%m;p=p>>1;}return x;}
//---- Debugger ---- //
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli fact[1000100],inv_fact[1000100];
lli nCr(lli n,lli r){if(r>n || n<0 ||r<0)return 0;lli d=(inv_fact[r]*inv_fact[n-r])%M;  lli f=(fact[n]*d)%M;return f;}
lli nPr(lli n,lli r){return (nCr(n,r)*fact[r])%M;}
lli n,m,x,k,tt,q,p,y,h,w,l,r,d;
lli lcm(lli a,lli b){
    return (a*b/__gcd(a,b));
}
#undef mid
vi arr,brr;
vvi g,div1;

lli solve(lli n1,lli m1){
 cin>>l>>r;

 lli posl=-1,posr=-1;
 for(lli i=30;i>=0;i--){
   if(((l>>i)&1LL) && (posl==-1)){
    posl=i;
   }
   if(((r>>i)&1LL) && (posr==-1)){
    posr=i;
   }
 }

 if(abs(posr-posl)>=2){
  cout<<(1LL<<posr)<<" "<<(1LL<<(posr-1))<<" "<<((1LL<<(posr-1))-1)<<endl;
  return 1;
 }
 else if(posr-posl==1){
  if((r&(r-1))==0){
    cout<<r<<" "<<r-1<<" "<<r-2<<endl;
  }
  else{
    lli num=(1LL<<posr);
    cout<<num+1<<" "<<num<<" "<<num-1<<endl;
  }
  return 1;
 }

 for(lli i=30;i>=0;i--){
  lli nr=(r>>i)&1LL,nl=(l>>i)&1LL;
  if(nr==1 && nl==0){
    lli num=(1LL<<i);
    lli n1=r&((1LL<<(i+1))-1);
    lli lft=r-n1;
    if(n1==num){
     cout<<lft+n1<<" "<<lft+n1-1<<" "<<lft+n1-2<<endl;
    }
    else{
     cout<<lft+num+1<<" "<<lft+num<<" "<<lft+num-1<<endl;
    }
    return 1;
  }
 }

 return 1;
}

int main(){
 IOS

  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  //  fact[0]=1;
  //  for(lli i=1;i<=200200;i++){
  //    fact[i]=(i*fact[i-1])%M;
  //  }
  //  for(lli i=0;i<=200200;i++){
  //   inv_fact[i]=bin_pow<lli>(fact[i],M-2,M);
  //  }
//  deb(nCr(5,2));

//  div1.resize(1001000);
//  for(lli i=1;i<1001000;i++){
//   for(lli j=i;j<1001000;j+=i){
//     div1[j].pb(i);
//   }
//  }

//  pr(div1[10]);

cin>>tt;
// tt=1;
// lli cnt=1;
  while(tt--){
    solve(0,0);

  }

}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 //find_by order()->iterator of indexed element,  order_of_key()-> number of elements strictly less than x
#define lli long long int
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

#define endl '\n'
using pii=pair<lli,lli>;
#define MP make_pair
#define F first
#define ld long double
#define S second
#define all(o) o.begin(),o.end()
lli M=998244353;
using mll = map<lli,lli>;
using vi = vector<lli>;
using vvi = vector<vector<lli>>;
using vpii = vector<pii>;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mem(a,b) memset(a,b,sizeof(a))
#define state pair<lli,pii>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x) cout << #x << "=" << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define pb push_back
#define mid (l+r)/2
#define lb lower_bound
#define ub upper_bound
#define fr(i, a, b) for (lli i = a; i < b; i++)
#define rev(i, a, b) for (lli i = a; i >= b; i--)
template <typename T> T gcd(T a, T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T bin_pow(T b, T p, T m){T x = 1;while(p){if(p&1)x=(x*b)%m;b=(b*b)%m;p=p>>1;}return x;}
//---- Debugger ---- //
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli fact[1000100],inv_fact[1000100];
lli nCr(lli n,lli r){if(r>n || n<0 ||r<0)return 0;lli d=(inv_fact[r]*inv_fact[n-r])%M;  lli f=(fact[n]*d)%M;return f;}
lli nPr(lli n,lli r){return (nCr(n,r)*fact[r])%M;}
lli n,m,x,k,tt,q,p,y,h,w,l,r,d;
lli lcm(lli a,lli b){
    return (a*b/__gcd(a,b));
}

vvi arr,brr;
vvi g,pref,pref1,ans;
string str;
map<char,pii> mp;

lli rec(lli lvl,lli i,lli j,lli sum,lli rsum,lli csum){
  // deb2(i,j);

  auto [dx,dy]=mp[str[lvl]];
  lli ni=i+dx,nj=j+dy;

  lli ff=0;
  if(ni==n-1 && nj==m-1){
    if(str[lvl]=='R'){
      lli num1=sum-pref1[0][m-1];
      lli num2=sum-(pref[n-1][0]+rsum);
      ans[ni][nj]=num1;
      return num1==num2;
    }
    else{
      lli num1=sum-pref[n-1][0];
      lli num2=sum-(pref[0][m-1]+csum);
      ans[ni][nj]=num1;
      return num1==num2;
    }
  }
  else{
    if(str[lvl]=='R'){
      if(str[lvl+1]=='R'){
         ans[ni][nj]=sum-pref1[0][nj];
         ff=rec(lvl+1,ni,nj,sum,rsum+ans[ni][nj],0);
      }
      else
        if(str[lvl+1]=='D'){
         ans[ni][nj]=sum-(pref[ni][0]+rsum);
         ff=rec(lvl+1,ni,nj,sum,0,ans[ni][nj]);
        }
    }
    else{
      if(str[lvl+1]=='D'){
         ans[ni][nj]=sum-pref[ni][0];
         ff=rec(lvl+1,ni,nj,sum,0,csum+ans[ni][nj]);
      }
      else
        if(str[lvl+1]=='R'){
         ans[ni][nj]=sum-(pref1[0][nj]+csum);
         ff=rec(lvl+1,ni,nj,sum,ans[ni][nj],0);
        }
    }
  }

  return ff;

}

lli solve(lli n1,lli m1){
  cin>>n>>m;
  pref.assign(n,vi(m,0));
  pref1.assign(n,vi(m,0));
  ans.assign(n,vi(m,0));
  arr.assign(n,vi(m,0));
  cin>>str;

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
     cin>>arr[i][j];
     ans[i][j]=arr[i][j];
    }
  }

  for(int i=0;i<n;i++){
    for(int j=m-1;j>=0;j--){
      pref[i][j]=arr[i][j];
      if(j+1<m){
        pref[i][j]+=pref[i][j+1];
      }
    }
  }

  for(int j=0;j<n;j++){
    for(int i=n-1;i>=0;i--){
      pref1[i][j]=arr[i][j];
      if(i+1<n){
        pref1[i][j]+=pref1[i+1][j];
      }
    }
  }

  lli sum=0,rsum=0,csum=0;
  if(str[0]=='D'){
    sum=pref[0][0];
  }
  else{
    sum=pref1[0][0];
  }

  lli x=rec(0,0,0,sum,0,0);
  assert(x==1);
  ans[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
  return 1;
}

int main(){
 IOS

  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
//    fact[0]=1;
//    for(lli i=1;i<1000100;i++){
//      fact[i]=(i*fact[i-1])%M;
//    }
//    for(lli i=0;i<1000100;i++){
//     inv_fact[i]=bin_pow<lli>(fact[i],M-2,M);
//    }
//  deb(nCr(5,2));

//  div1.assign(1000100,0);

//  for(lli i=1;i<1000100;i++){
//   for(lli j=i;j<1000100;j+=i){
//     div1[j]++;
//   }
//  }

// deb(div1[2]);
mp['D']=MP(1,0);
mp['R']=MP(0,1);

cin>>tt;
// tt=1;
// lli cnt=1;
  while(tt--){
    solve(0,0);
  }

}

Answer: 1


/*Author : KRISH JHA */
/*scholar id : 2312119*/

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

#define endl "\n"
#define allv  v.begin() , v.end()
#define rallv v.rbegin() , v.rend()
#define yes   cout<<"YES\n"
#define no    cout<<"NO\n"

/********************************************** Debug Code **************************************************/
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename A>
void __print(const A &x);
template <typename A, typename B>
void __print(const pair<A, B> &p);
template <typename... A>
void __print(const tuple<A...> &t);
template <typename T>
void __print(stack<T> s);
template <typename T>
void __print(queue<T> q);
template <typename T, typename... U>
void __print(priority_queue<T, U...> q);
template <typename A>
void __print(const A &x) {
    bool first = true;
    cerr << '{';
    for (const auto &i : x) {
        cerr << (first ? "" : ","), __print(i);
        first = false;
    }
    cerr << '}';
}
template <typename A, typename B>
void __print(const pair<A, B> &p) {
    cerr << '(';
    __print(p.first);
    cerr << ',';
    __print(p.second);
    cerr << ')';
}
template <typename... A>
void __print(const tuple<A...> &t) {
    bool first = true;
    cerr << '(';
    apply([&first](const auto &...args) { ((cerr << (first ? "" : ","), __print(args), first = false), ...); }, t);
    cerr << ')';
}
template <typename T>
void __print(stack<T> s) {
    vector<T> debugVector;
    while (!s.empty()) {
        T t = s.top();
        debugVector.push_back(t);
        s.pop();
    }
    reverse(debugVector.begin(), debugVector.end());
    __print(debugVector);
}
template <typename T>
void __print(queue<T> q) {
    vector<T> debugVector;
    while (!q.empty()) {
        T t = q.front();
        debugVector.push_back(t);
        q.pop();
    }
    __print(debugVector);
}
template <typename T, typename... U>
void __print(priority_queue<T, U...> q) {
    vector<T> debugVector;
    while (!q.empty()) {
        T t = q.top();
        debugVector.push_back(t);
        q.pop();
    }
    __print(debugVector);
}
void _print() { cerr << "]\n"; }
template <typename Head, typename... Tail>
void _print(const Head &H, const Tail &...T) {
    __print(H);
    if (sizeof...(T))
        cerr << ", ";
    _print(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "Line:" << __LINE__ << " [" << #__VA_ARGS__ << "] = ["; _print(__VA_ARGS__)
#else
#define debug(...)
#endif
/****************************************** Debug Code Ends ***************************************************************************************/

int gcd(int a , int b){if(a == 0) return b;return gcd( b % a , a);}

bool comp(pair<int,int> a , pair<int , int> b){
   return a.first > b.first;
}

int findmax(int a , int b){if(a > b) return a;else return b;}

#define int long long

/********************************************* Code starts from here  *************************************************/

void solve(){

    int l , r;
    cin >> l >> r;

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

    int a = 0 , b = 0 , c = 0;
    for(int i = 29 ; i >= 0; i--){
        if((l & (1 << i)) != (r & (1 << i))){
            a |= (1 << i);
            break;
        }
        else{
            a |= (l & (1 << i));
        }
    }

    b = a - 1;

    for(int i = l ;i <= r ; i++){
        if(i != a && i != b) {
            c = i;
            break;
        }
    }

    cout << a << ' ' << b  << ' ' << c << endl;

}

signed main() {

    #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif

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

    // int t = 1;

    int t;
    cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;

}

/*Author : KRISH JHA */
/*scholar id : 2312119*/

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

#define endl "\n"
#define allv  v.begin() , v.end()
#define rallv v.rbegin() , v.rend()
#define yes   cout<<"YES\n"
#define no    cout<<"NO\n"

/********************************************** Debug Code **************************************************/
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename A>
void __print(const A &x);
template <typename A, typename B>
void __print(const pair<A, B> &p);
template <typename... A>
void __print(const tuple<A...> &t);
template <typename T>
void __print(stack<T> s);
template <typename T>
void __print(queue<T> q);
template <typename T, typename... U>
void __print(priority_queue<T, U...> q);
template <typename A>
void __print(const A &x) {
    bool first = true;
    cerr << '{';
    for (const auto &i : x) {
        cerr << (first ? "" : ","), __print(i);
        first = false;
    }
    cerr << '}';
}
template <typename A, typename B>
void __print(const pair<A, B> &p) {
    cerr << '(';
    __print(p.first);
    cerr << ',';
    __print(p.second);
    cerr << ')';
}
template <typename... A>
void __print(const tuple<A...> &t) {
    bool first = true;
    cerr << '(';
    apply([&first](const auto &...args) { ((cerr << (first ? "" : ","), __print(args), first = false), ...); }, t);
    cerr << ')';
}
template <typename T>
void __print(stack<T> s) {
    vector<T> debugVector;
    while (!s.empty()) {
        T t = s.top();
        debugVector.push_back(t);
        s.pop();
    }
    reverse(debugVector.begin(), debugVector.end());
    __print(debugVector);
}
template <typename T>
void __print(queue<T> q) {
    vector<T> debugVector;
    while (!q.empty()) {
        T t = q.front();
        debugVector.push_back(t);
        q.pop();
    }
    __print(debugVector);
}
template <typename T, typename... U>
void __print(priority_queue<T, U...> q) {
    vector<T> debugVector;
    while (!q.empty()) {
        T t = q.top();
        debugVector.push_back(t);
        q.pop();
    }
    __print(debugVector);
}
void _print() { cerr << "]\n"; }
template <typename Head, typename... Tail>
void _print(const Head &H, const Tail &...T) {
    __print(H);
    if (sizeof...(T))
        cerr << ", ";
    _print(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "Line:" << __LINE__ << " [" << #__VA_ARGS__ << "] = ["; _print(__VA_ARGS__)
#else
#define debug(...)
#endif
/****************************************** Debug Code Ends ***************************************************************************************/

int gcd(int a , int b){if(a == 0) return b;return gcd( b % a , a);}

bool comp(pair<int,int> a , pair<int , int> b){
   return a.first > b.first;
}

int findmax(int a , int b){if(a > b) return a;else return b;}

#define int long long

/********************************************* Code starts from here  *************************************************/

void solve(){

    int l , r;
    cin >> l >> r;

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

    int a = 0 , b = 0 , c = 0;
    for(int i = 29 ; i >= 0; i--){
        if((l & (1 << i)) != (r &  (1 << i))){
            a |= (1 << i);
            break;
        }
    }

    b = a - 1;

    for(int i = l ;i <= r ; i++){
        if(i != a && i != b) {
            c = i;
            break;
        }
    }

    cout << a << ' ' << b  << ' ' << c << endl;

}

signed main() {

    #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif

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

    // int t = 1;

    int t;
    cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;

}

Answer: 1


#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define dbg(x) cerr << #x << ": " << x << '\n';
#define dbgv(v) cerr << #v << ": "; for(auto &el : v) cerr << el << " "; cerr << '\n';

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 5;

void solve(){
    int l, r;
    cin >> l >> r;
    int log = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << log) - 1), b = a + 1, c = (a == l ? r : r);
    cout << a << " " << b << " " << c << "\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}

#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define dbg(x) cerr << #x << ": " << x << '\n';
#define dbgv(v) cerr << #v << ": "; for(auto &el : v) cerr << el << " "; cerr << '\n';

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 5;

void solve(){
    int l, r;
    cin >> l >> r;
    int log = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << log) - 1), b = a + 1, c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}

Answer: 2


#include <bits/stdc++.h>
#define lli long long
#define endl "\n"
#define vi vector<lli>
#define vpi vector<pair<lli, lli>>
#define vvi vector<vector<lli>>
#define fo(i, a, n) for(lli i = a; i<n; i++)
#define rfo(i, a, n) for(lli i = n-1; i>=a; i--)
#define nay {cout << "No\n"; return;}
#define yay {cout << "Yes\n"; return;}
#define vin(v) for(auto&x:v)cin>>x;
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define all(v) v.begin(),v.end()
#define pb push_back
using namespace std;

const lli MOD = 1e9+7;

string num_to_bin(lli n) {
    string ans;
    if (n==0) return "0";
    while (n!=0) {
        if (n%2==0) ans.push_back('0');
        else ans.push_back('1');
        n/=2;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

void solve() {
    lli l,r; cin >> l >> r;
    lli a = 0, b = 0;
    for (int i=30; i>=0; i--) {
        lli b1 = l & (1ll << i);
        lli b2 = r & (1ll << i);
        if (b1 == b2) {
            b += b1 * (1ll << i);
        }
        else {
            b += (1ll << i);
            a = b-1;
            break;
        }
    }
    lli c;
    if (l<=a-1 && r>=a-1) c = a-1;
    else c = b+1;
    cout << a << " " << b << " " << c << endl;
}

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

#include <bits/stdc++.h>
#define lli long long
#define endl "\n"
#define vi vector<lli>
#define vpi vector<pair<lli, lli>>
#define vvi vector<vector<lli>>
#define fo(i, a, n) for(lli i = a; i<n; i++)
#define rfo(i, a, n) for(lli i = n-1; i>=a; i--)
#define nay {cout << "No\n"; return;}
#define yay {cout << "Yes\n"; return;}
#define vin(v) for(auto&x:v)cin>>x;
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define all(v) v.begin(),v.end()
#define pb push_back
using namespace std;

const lli MOD = 1e9+7;

string num_to_bin(lli n) {
    string ans;
    if (n==0) return "0";
    while (n!=0) {
        if (n%2==0) ans.push_back('0');
        else ans.push_back('1');
        n/=2;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

void solve() {
    lli l,r; cin >> l >> r;
    lli a = 0, b = 0;
    for (int i=30; i>=0; i--) {
        lli b1=0, b2=0;
        if (l & (1ll << i)) b1 = 1;
        if (r & (1ll << i)) b2 = 1;
        if (b1 == b2) {
            b += b1 * (1ll << i);
        }
        else {
            b += (1ll << i);
            a = b-1;
            break;
        }
    }
    lli c;
    if (l<=a-1 && r>=a-1) c = a-1;
    else c = b+1;
    cout << a << " " << b << " " << c << endl;
}

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

Answer: 2


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

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=30; i>=0; i--){
       int a1=0,a2=0;
       if(a&(1ll<<i)){a1=1;}
       if(b&(1ll<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1ll<<i);
       }
       else{
        aa=ans+(1ll<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }

    return 0;
}

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

void sol1(){
    int a,b,c, ans=0, i=0; cin>>a>>b;
    vector<pair<int, int>>vp;
    unordered_map<int,int>mp;
    while(a--){cin>>c; mp[c]++;}
    for(auto &b: mp){vp.push_back({b.second, b.first});}
    sort(vp.begin(), vp.end());
    while(b>0 and i<vp.size()){
        int minn=min(b, vp[i].first);
        vp[i].first-=minn; b-=minn; i++;
    }
    for(auto &b: vp){
        if(b.first>0){ans++;}
    }
    cout<<max(1LL,ans)<<"\n";
}
void sol2(){
    int a,b,aa,bb,cc,ans=0; cin>>a>>b;
    for(int i=30; i>=0; i++){
       int a1=0,a2=0;
       if(a&(1ll<<i)){a1=1;}
       if(b&(1ll<<i)){a2=1;}
       if(a1==a2){
          ans+=a1*(1ll<<i);
       }
       else{
        aa=ans+(1ll<<i);
        bb=aa-1;
        break;
       }
    }
    for(int i=a; i<=b; i++){
        if(i!=aa and i!=bb){
            cc=i; break;
        }
    }
    cout<<aa<<" "<<bb<<" "<<cc<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t; cin>>t;
    while(t--){
    //   sol1();
        sol2();
    }

    return 0;
}

Answer: 1


Answer: 2


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define iii pair<int, ii>
#define fi first
#define se second
#define inf 1e16
int tc, l, r;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen("main.inp","r")) {
        freopen("main.inp", "r", stdin);
        freopen("main.out", "w", stdout);
    }
    cin >> tc;
    while(tc--) {
        cin >> l >> r;
        int a = 0, b = 0, c =  0;
        for(int j = 30; j >= 0; j--) {
            if((r&(1<<j)) && (l&(1<<j))) {
                a += (1<<j);
                b += (1<<j);
                c += (1<<j);
            }
            else if(!(r&(1<<j)) && !(l&(1<<j))) continue;
            else {
                a += (1<<j);
                b += (1<<j)-1;
                c += (1<<j)-2;
                break;
            }
        }
        if(min({a,b,c}) < l) {
            a++;
            b++;
            c++;
        }
        cout << a << ' ' << b << ' ' << c << '\n';
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int mod=1e9+7;
long long power(long long x,int y)
{
    long long res=1;
    while(y>0)
    {
        int r=y%2;
        if(r==1)
        {
            res=res*x;
        }
        y=y/2;
        x=x*x;
    }
    return res;
}
int main() {
    int t;
    cin>>t;
    while(t--)
    {
       long long low,l,high,h;
       cin>>low>>high;
       l=low;
       h=high;
       vector<int>v1(35,0),v2(35,0);
       int j=32;
      // long long p=1;
       while(high>0)
       {
           int r1=high%2;
           int r2=low%2;
           v1[j]=r1;
           v2[j]=r2;
           j--;

           high=high/2;
           low=low/2;

        }
       // cout<<j<<endl;
        long long z=0;
        int idx;
        for(int i=0;i<=32;i++)
        {
            if(v1[i]==v2[i])
            {
                continue;
            }
            idx=33-i;

           z=power(2,idx);
            z--;
            break;
        }
    //     cout<<z<<endl;
      //  cout<<z;
        long long num1=l^z;
        long long num2=h^z;
        if(num1<high&&num1>low)
        {
            cout<<l<<" "<<num1<<" "<<h<<endl;
        }
        else if(num2>low&&num2<high){
             cout<<l<<" "<<num2<<" "<<h<<endl;
        }
        else{
            cout<<l<<" "<<l+1<<" "<<h<<endl;
        }
    }

    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())cout<<(1<< sr.length()-1)<<" " << (1 << sr.length() - 1) - 1 << " " << t << endl;
    else {
        c = sr.size()-1;
        while (sr[c] == sl[c])c--;
        cout << (1 << c) << " " << (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


#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    lli t;
    cin >> t;
    while (t--)
    {
        lli left, right;
        cin >> left >> right;
        // if leading_zeros_left==leading_zeros_right-->choose one number as first odd second number as right and greedy approach to choose third
        // else -->first number as (set bit 1 after min leading zeros and all zeros after that ->and seoond num as first-1 and greedy to choose third)
        // cout << __builtin_clzll(left) << " " << __builtin_clzll(right) << endl;
        if (__builtin_clzll(left) == __builtin_clzll(right))
        {
            lli first = right;
            lli second;
            for (lli i = left; i < right; i++)
            {
                if (i % 2 != 0)
                {
                    second = i;
                    break;
                }
            }
            lli maxi = -1;
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    if (((first ^ i) + (second ^ i)) > maxi)
                    {
                        maxi = (first ^ i) + (second ^ i);
                        third = i;
                    }
                }
            }
            cout << first << " " << second << " " << third << endl;
            // cout << (first ^ second) + maxi << endl;
            // cout << (123 ^ 118) + (123 ^ 121) + (121 ^ 118) << endl;
        }
        else
        {
            lli max_leading = __builtin_clzll(right);
            bitset<64> b;
            b[63 - max_leading] = 1;
            lli first = b.to_ullong();
            lli second = first - 1;
            lli maxi = -1;
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    if (((first ^ i) + (second ^ i)) > maxi)
                    {
                        maxi = (first ^ i) + (second ^ i);
                        third = i;
                        break;
                    }
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    lli t;
    cin >> t;
    while (t--)
    {
        lli left, right;
        cin >> left >> right;
        // if leading_zeros_left==leading_zeros_right-->choose one number as first odd second number as right and greedy approach to choose third
        // else -->first number as (set bit 1 after min leading zeros and all zeros after that ->and seoond num as first-1 and greedy to choose third)
        // cout << __builtin_clzll(left) << " " << __builtin_clzll(right) << endl;
        if (__builtin_clzll(left) == __builtin_clzll(right))
        {
            // cout << "came here" << endl;
            lli first_difference = __builtin_clzll(left ^ right);
            bitset<64> b(left);
            b[63 - first_difference] = 1;
            for (lli i = 0; i < 63 - first_difference; i++)
            {
                b[i] = 0;
            }
            bitset<64> b1(left);
            for (lli i = 0; i < 63 - first_difference; i++)
            {
                b1[i] = 1;
            }
            b1[63 - first_difference] = 0;
            lli first = b.to_ullong();
            lli second = b1.to_ullong();
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    third = i;
                    break;
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
        else
        {
            lli max_leading = __builtin_clzll(right);
            bitset<64> b;
            b[63 - max_leading] = 1;
            lli first = b.to_ullong();
            lli second = first - 1;
            lli maxi = -1;
            lli third;
            for (lli i = left; i <= right; i++)
            {
                if (i != first && i != second)
                {
                    if (((first ^ i) + (second ^ i)) > maxi)
                    {
                        maxi = (first ^ i) + (second ^ i);
                        third = i;
                        break;
                    }
                }
            }
            cout << first << " " << second << " " << third << endl;
        }
    }
}

Answer: 2


#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#define ll long long
#define int long long
#define DEBUG false
using namespace std;

void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}

void debug(vector<int> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

class Solution {
    int l, r;
public:
    void init() {
        cin >> l >> r;
    }

    ll solve() {
        init();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 30; i >= 0; --i) {
            int li = (l >> i) & 1;
            int ri = (r >> i) & 1;
            if (li != ri) {
                if (r > (1 << i)) {
                    a += (1 << i) + 1;
                    b += (1 << i);
                    c += (1 << i) - 1;
                } else {
                    a += (1 << i);
                    b += (1 << i) - 1;
                    c += (1 << i) - 2;
                }
                break;
            } else if (li == 1) {
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
                l -= (1 << i);
                r -= (1 << i);
            }
        }

        cout << a << " " << b << " " << c << endl;
        return 0;
    }

};

signed main()
{
    std::ios_base::sync_with_stdio (false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        //cout << fixed << setprecision(0) << sol.solve() << "\n";
        sol.solve();
    }

    return 0;
}

#include <algorithm>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits.h>
#include <climits>
#include <numeric>
#include <map>
#include <unordered_map>
#include <cfloat>
#define ll long long
#define int long long
#define DEBUG false
using namespace std;

void debug(string s) {
    if (DEBUG) cout << s << endl;
}

void debug(int s) {
    if (DEBUG) cout << s << endl;
}

void debug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

//flat debug of vector of vectors
void fdebug(vector<vector<int> > & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        for (int j = 0; j != v[i].size(); ++j) {
            cout << v[i][j];
            if (j != v[i].size() - 1) {
                cout << " ";
            }
        }
        cout << "; ";
    }
    cout << endl;
}

void debug(vector<int> & v) {
    if (!DEBUG) return;
    for (int i = 0; i != v.size(); ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
}

class Solution {
    int l, r;
public:
    void init() {
        cin >> l >> r;
    }

    ll solve() {
        init();
        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 30; i >= 0; --i) {
            int li = (l >> i) & 1;
            int ri = (r >> i) & 1;
            if (li != ri) {
                if (r > (1 << i)) {
                    a += (1 << i) + 1;
                    b += (1 << i);
                    c += (1 << i) - 1;
                } else {
                    a += (1 << i);
                    b += (1 << i) - 1;
                    c += (1 << i) - 2;
                }
            } else if (li == 1) {
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
        }

        cout << a << " " << b << " " << c << endl;
        return 0;
    }

};

signed main()
{
    std::ios_base::sync_with_stdio (false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    Solution sol;
    for(int i = 1; i != n + 1; ++i) {
        //cout << fixed << setprecision(0) << sol.solve() << "\n";
        sol.solve();
    }

    return 0;
}

Answer: 1


#include <bits/stdc++.h>
using namespace std;
#define vii vector<vector<int>>
#define vi vector<int>
#define pb push_back
#define int long long
#define double long double
#define fi first
#define se second
#define s(v) sort(v.begin(), v.end())
#define r(v) reverse(v.begin(), v.end())
#define fast                         \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
void solve()
{
   int l, r;
   cin >> l >> r;
   bool flag = 0;
   int a = 0, b = 0, c = 0;
   for (int i = 31; i >= 0; i--)
   {
      int l_bit = (l & (1LL << i)) > 0;
      int r_bit = (r & (1LL << i)) > 0;
      if (l_bit == r_bit && !flag)
      {
         if (l_bit)
         {
            a |= (1LL << i);
            b |= (1LL << i);
            c |= (1LL << i);
         }
      }
      else
      {
         if (flag == 0)
         {
            flag = 1;
            a |= (1LL << i);
         }
         else
         {
            b |= (1LL << i);
         }
      }
   }
   cout << a << " " << b << " " << c << endl;
}
int32_t main()
{
   fast int t;
   cin >> t;
   while (t--)
      solve();
   return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define vii vector<vector<int>>
#define vi vector<int>
#define pb push_back
#define int long long
#define double long double
#define fi first
#define se second
#define s(v) sort(v.begin(), v.end())
#define r(v) reverse(v.begin(), v.end())
#define fast                         \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
void solve()
{
   int l, r;
   cin >> l >> r;
   bool flag = 0;
   int a = 0, b = 0, c = 0;
   for (int i = 31; i >= 0; i--)
   {
      int l_bit = (l & (1LL << i)) > 0;
      int r_bit = (r & (1LL << i)) > 0;
      if (l_bit == r_bit && !flag)
      {
         if (l_bit)
         {
            a |= (1LL << i);
            b |= (1LL << i);
            c |= (1LL << i);
         }
      }
      else
      {
         if (flag == 0)
         {
            flag = 1;
            a |= (1LL << i);
            c |= (1LL << i);
         }
         else
         {
            b |= (1LL << i);
            // c |= (1LL << i);
         }
      }
   }
   for (int i = l; i <= r; i++)
   {
      if (i != a && i != b)
      {
         cout << a << " " << b << " " << i << endl;
         return;
      }
   }
}
int32_t main()
{
   fast int t;
   cin >> t;
   while (t--)
      solve();
   return 0;
}

Answer: 2


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

int get_highest_diff_bin_bit(int l, int r){
    int diff = (l ^ r);
    int cnt = 0;
    while(diff){
        diff >>= 1;
        cnt++;
    }
    return cnt;
}

int get_bit_num(int n){
    int cnt = 0;
    while(n){
        n >>= 1;
        cnt++;
    }
    return cnt;
}

int rand_from_l_to_r(int l, int r, int first, int second){
    int res = rand() % (r - l + 1) + l;
    // cout << "l: "<<l << " r: "<<r << endl;
    while (res == first || res == second)
    {
        res = rand() % (r - l + 1) + l;

    }
    return res;
}

int main(){
    int k,l,r;
    cin >> k ;
    for (int i=0; i< k; i++){
        cin >> l >> r;
        //cout << two_sum << endl;
        int first =  l >> (get_highest_diff_bin_bit(l, r)-1);
        // cout << "prefix:" << first << endl;
        first <<= (get_highest_diff_bin_bit(l, r)-1);

        int mask = (1 << (get_highest_diff_bin_bit(l, r)-1)) - 1;

        first |= mask;

        int second = r >> (get_highest_diff_bin_bit(l, r)-1);
        // cout << "prefix:" << second << endl;
        second <<= (get_highest_diff_bin_bit(l, r)-1);

        int third = rand_from_l_to_r(l, r, first, second);
        cout << first << " " << second << " " << third << endl;
    }

    return 0;
}

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

int get_highest_diff_bin_bit(int l, int r){
    int diff = (l ^ r);
    int cnt = 0;
    while(diff){
        diff >>= 1;
        cnt++;
    }
    return cnt;
}

int get_bit_num(int n){
    int cnt = 0;
    while(n){
        n >>= 1;
        cnt++;
    }
    return cnt;
}

int main(){
    int k,l,r;
    cin >> k ;
    for (int i=0; i< k; i++){
        cin >> l >> r;
        //cout << two_sum << endl;
        int first =  l >> (get_highest_diff_bin_bit(l, r)-1);
        // cout << "prefix:" << first << endl;
        first <<= (get_highest_diff_bin_bit(l, r)-1);

        int mask = (1 << (get_highest_diff_bin_bit(l, r)-1)) - 1;

        first |= mask;

        int second = r >> (get_highest_diff_bin_bit(l, r)-1);
        // cout << "prefix:" << second << endl;
        second <<= (get_highest_diff_bin_bit(l, r)-1);

        int third = l+1;
        cout << first << " " << second << " " << third << endl;
    }

    return 0;
}

Answer: 1


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

#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

    int max_val = l;

    for(int i=0;i<30;i++){
        int num = pow(2,i);
        if(num>=l&&num<=r) max_val=max(max_val,num);
    }

    // If-else case
    int a,b,c;

    if(max_val==l){

        a=l;
        b=l+1;
        c=r;

    }else if(max_val==r){

        a=r;
        b=r-1;
        c=l;

    }else{

        a=max_val;
        b=a-1;
        int check1 = (a^r)+(b^r);
        int check2 = (a^l)+(b^l);
        if(check1>check2) c=r;
        else c=l;
        if(b==l) c=r;

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

signed main() {
    fastio();

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}

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

#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

    // int max_val = l;

    // for(int i=0;i<30;i++){
    //     int num = pow(2,i);
    //     if(num>=l&&num<=r) max_val=max(max_val,num);
    // }

    // // If-else case
    // int a,b,c;

    // if(max_val==l){

    //     a=l;
    //     c=r;
    //     int num1 = -1;

    //     for(int i=l+1;i<r;i++){
    //         if(num1<=((a^i)+(c^i))){
    //             num1 = max(num1,(a^i+c^i));
    //             b=i;
    //         }
    //     }

    // }else if(max_val==r){

    //     a=r;
    //     b=r-1;
    //     c=l;

    // }else{

    //     a=max_val;
    //     b=a-1;
    //     int check1 = (a^r)+(b^r);
    //     int check2 = (a^l)+(b^l);
    //     if(check1>check2) c=r;
    //     else c=l;
    //     if(b==l) c=r;

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

    int l, r;
    cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r); // Trailing zeroes of l^r
    int a =(pow(2,k) - 1);
    a=a|l;
    int b = a + 1;
    int c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}

signed main() {
    fastio();

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}

Answer: 2


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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = l | ((1 << (int)(log2(l ^ r))) - 1);
		int b = a + 1;
		int c = (b == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		int b = (a - 1 >= l ? a - 1 : a + 1);
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

Answer: 1


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long int ll;
typedef long double ld;

const ld eps = 1e-9;
const int mod = 1000000007;
const ll inf = 1e18;
const int N1 = 2e5 + 10;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // mt19937 rng((unsigned int)chrono::steady_clock::now().time_since_epoch().count());
    // auto start = chrono::high_resolution_clock::now();

    // code here. dont use mbinpow,binpow,right, fact and isprime as function names
    // (1/b)%M is (b^(M-2))%M

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

        int k = 0;
        for(int i=0;i<30;i++){
            if((l&(1<<i))^(r&(1<<i))){
                k = i;
            }
        }

        int val1 = (r >> k) << k;
        int val2 = val1 - 1;
        int val3;
        for (int i = l; i < min(l + 3, r);i++){
            if(i!=val1 && i!=val2){
                val3 = i;
                break;
            }
        }

        cout << val1 << " " << val2 << " " << val3 << '\n';
    }

}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long int ll;
typedef long double ld;

const ld eps = 1e-9;
const int mod = 1000000007;
const ll inf = 1e18;
const int N1 = 2e5 + 10;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // mt19937 rng((unsigned int)chrono::steady_clock::now().time_since_epoch().count());
    // auto start = chrono::high_resolution_clock::now();

    // code here. dont use mbinpow,binpow,right, fact and isprime as function names
    // (1/b)%M is (b^(M-2))%M

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

        int k = 0;
        for(int i=0;i<30;i++){
            if((l&(1<<i))^(r&(1<<i))){
                k = i;
            }
        }

        int val1 = (r >> k) << k;
        int val2 = val1 - 1;
        int val3;
        for (int i = l; i <= min(l + 2, r);i++){
            if(i!=val1 && i!=val2){
                val3 = i;
                break;
            }
        }

        cout << val1 << " " << val2 << " " << val3 << '\n';
    }

}

Answer: 2