#pragma GCC optimize(2)

#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int INF=0x3f3f3f3f;

const int mod=1e9+7;

const int N=200005;

int a[N];

void solve(){

    int n,x,y;cin>>n>>x>>y;

    for(int i=1;i<=n;i++)a[i]=i%2;

    if(n%2)a[n]=2;

    if(a[x]==a[y]){

        if(a[n]==2){

            for(int i=1;i<n;i++){

                if(i==x)cout<<a[i]<<" 2 ";

                else cout<<a[i]<<" ";

            }

            cout<<endl;

            return;

        }

        else{

            if(y!=n){

                for(int i=1;i<n-1;i++){

                    if(i==x)cout<<a[i]<<" 2 ";

                    else cout<<a[i]<<" ";

                }

                cout<<2<<endl;

                return;

            }

            else{

                for(int i=2;i<=n;i++){

                    cout<<a[i]<<" ";

                }

                cout<<2<<endl;

                return;

            }

        }

    }

    for(int i=1;i<=n;i++)cout<<a[i]<<(i==n?endl:" ");

}

int main(){

    std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int _=1;cin>>_;

    while(_--){

        solve();

    }

    return 0;

}

#pragma GCC optimize(2)

#include<bits/stdc++.h>

using namespace std;

#define ll long long

const int INF=0x3f3f3f3f;

const int mod=1e9+7;

const int N=200005;

int a[N];

void solve(){

    int n,x,y;cin>>n>>x>>y;

    for(int i=1;i<=n;i++)a[i]=i%2;

    if(n%2)a[n]=2;

    if(a[x]==a[y]){

        if(a[n]==2){

            for(int i=1;i<n;i++){

                if(i==x)cout<<a[i]<<" 2 ";

                else cout<<a[i]<<" ";

            }

            cout<<endl;

            return;

        }

        else{

            if(y!=n){

                for(int i=1;i<n-1;i++){

                    if(i==x)cout<<a[i]<<" 2 ";

                    else cout<<a[i]<<" ";

                }

                cout<<2<<endl;

                return;

            }

            else{

                for(int i=2;i<=n;i++){

                    cout<<a[i]<<" ";

                }

                cout<<2<<endl;

                return;

            }

        }

    }

    for(int i=1;i<=n;i++)cout<<a[i]<<(i==n?"\n":" ");

}

int main(){

    std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int _=1;cin>>_;

    while(_--){

        solve();

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long ll;

typedef vector<ll> vi;

typedef vector<char> vc;

typedef vector<long long> vll;

typedef unsigned long long ull;

typedef vector<pair<ll, ll>> vpii;

typedef vector<pair<ll, char>> vpic;

#define for1(i, n1, n2) for(ll i = n1; i < n2; i++)

#define for2(i, n2, n1) for(ll i = n2; i > n1; i--)

#define vecMAX(v) *max_element(v.begin(), v.end())

#define vecMIN(v) *min_element(v.begin(), v.end())

#define srt(v) sort(v.begin(), v.end())

#define rev(v) reverse(v.begin(), v.end())

#define pb push_back

#define inx ll p[0]; cin >> p[0];

#define vin(v) for(auto &it : v) cin >> it;

#define mp make_pair

#define ff first

#define ss second

#define v_erase(i) v.erase(v.begin() + i);

#define sum(v) accumulate(v.begin(), v.end(), 0)

#define INF 1e9

#define MOD 1000000007

#define sz(v) ((ll)(v).size())

#define Code_by_Millenialkiid ios::sync_with_stdio(0); cin.tie(0);

#ifndef ONLINE_JUDGE

    #include "Jatt_don't_Care.h"

#else

    #define see(...) 42

#endif

void solve() {

ll n,x,y;

cin>>n>>x>>y;

x--,y--;

if(n%2==0&&abs(x-y)%2){

    for1(i,0,n)cout<<i%2<<" ";

    return;

}

for1(i,0,n){

    if(x==i){

        cout<<2<<" ";

    }else{

        if(n%2==1){

        cout<<(i+1)%2<<" ";

        }else{

            cout<<i%2<<" ";

        }

    }

}

cout<<"\n";

}

signed main() {

   Code_by_Millenialkiid

   ll t;

    cin >> t;

    for (ll i = 0; i < t; i++) {

        #ifndef ONLINE_JUDGE

            cout << "-----------------" << i + 1 << endl;

        #endif

       solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long ll;

typedef vector<ll> vi;

typedef vector<char> vc;

typedef vector<long long> vll;

typedef unsigned long long ull;

typedef vector<pair<ll, ll>> vpii;

typedef vector<pair<ll, char>> vpic;

#define for1(i, n1, n2) for(ll i = n1; i < n2; i++)

#define for2(i, n2, n1) for(ll i = n2; i > n1; i--)

#define vecMAX(v) *max_element(v.begin(), v.end())

#define vecMIN(v) *min_element(v.begin(), v.end())

#define srt(v) sort(v.begin(), v.end())

#define rev(v) reverse(v.begin(), v.end())

#define pb push_back

#define inx ll p[0]; cin >> p[0];

#define vin(v) for(auto &it : v) cin >> it;

#define mp make_pair

#define ff first

#define ss second

#define v_erase(i) v.erase(v.begin() + i);

#define sum(v) accumulate(v.begin(), v.end(), 0)

#define INF 1e9

#define MOD 1000000007

#define sz(v) ((ll)(v).size())

#define Code_by_Millenialkiid ios::sync_with_stdio(0); cin.tie(0);

#ifndef ONLINE_JUDGE

    #include "Jatt_don't_Care.h"

#else

    #define see(...) 42

#endif

void solve() {

ll n,x,y;

cin>>n>>x>>y;

x--,y--;

if(n%2==0&&abs(x-y)%2){

    for1(i,0,n)cout<<i%2<<" ";

    return;

}

ll c=0;

for1(i,0,n){

    if(x==i){

        cout<<2<<" ";

        if(n%2==0){

        c+=1;

        c%=2;

        }

        continue;

    }

    cout<<c<<" ";

    c++;

    c%=2;

}

cout<<"\n";

}

signed main() {

   Code_by_Millenialkiid

   ll t;

    cin >> t;

    for (ll i = 0; i < t; i++) {

        #ifndef ONLINE_JUDGE

            cout << "-----------------" << i + 1 << endl;

        #endif

       solve();

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}

int findMex(int a, int b, int c) {

    set<int> s = {a, b, c}; // Store unique numbers

    for (int i = 0; ; i++) { // Check from 0 upwards

        if (s.find(i) == s.end()) return i;

    }

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vector<int>a(n);

	for(int i=0;i<n;i+=2){

		a[i]=1;

		}

	for(int i=1;i<n;i+=2){

		a[i]=0;

		}

	if(n%2==1){

		a[n-1]=2;

		}

	if((y-x)%2==0){

		if(n%2==1 && y-1==n-2){

			swap(a[n-1],a[n-2]);

			}

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool compareByFirst(const pair<int, int>& a, const pair<int, int>& b) {

    return a.first < b.first;

}

int findMex(int a, int b, int c) {

    set<int> s = {a, b, c}; // Store unique numbers

    for (int i = 0; ; i++) { // Check from 0 upwards

        if (s.find(i) == s.end()) return i;

    }

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vector<int>a(n);

	for(int i=0;i<n;i+=2){

		a[i]=1;

		}

	for(int i=1;i<n;i+=2){

		a[i]=0;

		}

	if(n%2==1){

		a[n-1]=2;

		}

	if((y-x)%2==0){

		if(n%2==1 && y-1==n-2){

			swap(a[n-1],a[n-2]);

			}

		else{

			a[y-1]=2;

			}

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}

Answer: 2


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define FASTIO() \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);

using namespace std;

//<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>

//                                                            DEBUG TEMPLATE

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 T, typename V>

void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>

void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>

void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define debug(x...)

#endif

// ordered set

// find_by_order, order_of_key

// order_of_key (k) : Number of items strictly smaller than k.

// find_by_order(k) : K-th element in a set (counting from zero)

using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;

template<class T> using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

struct pair_hash {

    template <class T1, class T2>

    size_t operator()(const std::pair<T1, T2>& p) const {

        auto h1 = std::hash<T1>{}(p.first);

        auto h2 = std::hash<T2>{}(p.second);

        return h1 ^ (h2 << 1);

    }

};

class DSU{

    public:

    vector<int> Rank, parent;

    void make(int n) {

        Rank.resize(n+1,0);

        parent.resize(n+1);

        for (int i = 0; i <= n; i++) {

            parent[i] = i;

        }

    }

    int get(int node) {

        if (node == parent[node])

            return node;

        return parent[node] = get(parent[node]);

    }

    void unite(int u, int v) {

        int ulp_u = get(u);

        int ulp_v = get(v);

        if (ulp_u == ulp_v) return;

        if (Rank[ulp_u] < Rank[ulp_v]) {

            parent[ulp_u] = ulp_v;

        }

        else if (Rank[ulp_v] < Rank[ulp_u]) {

            parent[ulp_v] = ulp_u;

        }

        else {

            parent[ulp_v] = ulp_u;

            Rank[ulp_u]++;

        }

    }

};

//<----------------------------------------------------------------------------------------------------------------------------------------------------------------------------->

void getpath(int n, unordered_map<int,set<int>>&mp, vector<int>&path, vector<int>&visited){

    queue<pair<int,int>>q; // node, parent

    q.push({path[0], -1});

    visited[path[0]] = 1;

    while(!q.empty()){

        auto [node, parent] = q.front();

        q.pop();

        for(auto &neigh: mp[node]){

            if(!visited[neigh]){

                visited[neigh] = 1;

                q.push({neigh, node});

                path.push_back(neigh);

                break;

            }

            else{

                if(neigh == parent) continue;

                return;

            }

        }

    }

}

void solve(){

    unordered_map<int,set<int>>mp;

    int n, x, y;

    cin >> n >> x >> y;

    for(int i = 1; i <= n; ++i){

        int f1 = i + 1, f2 = i - 1;

        if(f1 == n + 1) f1 = 1;

        if(f2 == 0) f2 = n;

        mp[i].insert(f1);

        mp[i].insert(f2);

    }

    mp[x].insert(y);mp[y].insert(x);

    bool exist = false;

    vector<int>path1, path2;

    for(int i = 1; i <= n; ++i){

        if(mp[i].size() == 3){

            path1.push_back(i);

            path2.push_back(i);

            exist = true;

            break;

        }

    }

    if(!exist){

        if(n % 2 == 0){

            for(int i = 1; i <= n; ++i){

                cout << (i % 2 == 1 ? 0 : 1) << " ";

            }

        }

        else{

            for(int i = 1; i <= 3; ++i){

                cout << i - 1 << " ";

            }

            for(int i = 4; i <= n; ++i){

                cout << (i % 2 == 1) << " ";

            }

        }

        cout << "\n";

        return;

    }

    //debug(path1, path2);

    vector<int>visited(n + 1, 0);

    int endnode = -1;

    getpath(n, mp, path1, visited);

    int nc1 = path2[0] + 1, nc2 = path2[0] - 1;

    if(nc1 == n + 1) nc1 = 1;

    if(nc2 == 0) nc2 = n;

    if(!visited[nc2]){

        for(int i = n; i >= 1; --i){

            if(visited[i]) continue;

            else{

                path2.push_back(i);

            }

        }

    }

    else{

        for(int i = 1; i <= n; ++i){

            if(visited[i]) continue;

            else{

                path2.push_back(i);

            }

        }

    }

    //debug(path1);

    path2.push_back(path1.back());

    //debug(path2);

    vector<int>ans(n + 1, -1);

    if(path1.size() % 2 == 1 and path2.size() % 2 == 1){

        ans[path1[0]] = 2;

        int i = 1;

        while(i < path1.size() or i < path2.size()){

            if(i < path1.size()){

                ans[path1[i]] = i % 2;

            }

            if(i < path2.size()){

                ans[path2[i]] = i % 2;

            }

            ++i;

        }

    }

    else if(path1.size() % 2 == 1){

        ans[path1[0]] = 0;

        ans[path1[1]] = 2;

        ans[path1[2]] = 1;

        for(int i = 3; i < path1.size(); ++i){

            if(i & 1) ans[path1[i]] = 0;

            else ans[path1[i]] = 1;

        }

        for(int i = 0; i < path2.size(); ++i){

            if(ans[path2[i]] != -1) continue;

            //debug(path2[i]);

            ans[path2[i]] = i % 2;

        }

    }

    else if(path2.size() % 2 == 1){

        ans[path2[0]] = 0;

        ans[path2[1]] = 2;

        ans[path2[2]] = 1;

        for(int i = 3; i < path2.size(); ++i){

            if(i & 1) ans[path2[i]] = 0;

            else ans[path2[i]] = 1;

        }

        for(int i = 0; i < path1.size(); ++i){

            if(ans[path1[i]] != -1) continue;

            ans[path1[i]] = i % 2;

        }

    }

    else{

        for(int i = 1; i <= n; ++i){

            ans[i] = (i % 2 == 0);

        }

    }

    for(int i = 1; i <= n; ++i){

        cout << ans[i] << " ";

    }

    cout << "\n";

}

int main() {

    FASTIO();

    int t; t = 1;

    cin >> t;

    while(t--){

        solve();

    }

}

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define FASTIO() \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);

using namespace std;

//<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>

//                                                            DEBUG TEMPLATE

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 T, typename V>

void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>

void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>

void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define debug(x...)

#endif

// ordered set

// find_by_order, order_of_key

// order_of_key (k) : Number of items strictly smaller than k.

// find_by_order(k) : K-th element in a set (counting from zero)

using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ;

template<class T> using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less<key>> using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

struct pair_hash {

    template <class T1, class T2>

    size_t operator()(const std::pair<T1, T2>& p) const {

        auto h1 = std::hash<T1>{}(p.first);

        auto h2 = std::hash<T2>{}(p.second);

        return h1 ^ (h2 << 1);

    }

};

class DSU{

    public:

    vector<int> Rank, parent;

    void make(int n) {

        Rank.resize(n+1,0);

        parent.resize(n+1);

        for (int i = 0; i <= n; i++) {

            parent[i] = i;

        }

    }

    int get(int node) {

        if (node == parent[node])

            return node;

        return parent[node] = get(parent[node]);

    }

    void unite(int u, int v) {

        int ulp_u = get(u);

        int ulp_v = get(v);

        if (ulp_u == ulp_v) return;

        if (Rank[ulp_u] < Rank[ulp_v]) {

            parent[ulp_u] = ulp_v;

        }

        else if (Rank[ulp_v] < Rank[ulp_u]) {

            parent[ulp_v] = ulp_u;

        }

        else {

            parent[ulp_v] = ulp_u;

            Rank[ulp_u]++;

        }

    }

};

//<----------------------------------------------------------------------------------------------------------------------------------------------------------------------------->

void getpath(int n, unordered_map<int,set<int>>&mp, vector<int>&path, vector<int>&visited){

    queue<pair<int,int>>q; // node, parent

    q.push({path[0], -1});

    visited[path[0]] = 1;

    while(!q.empty()){

        auto [node, parent] = q.front();

        q.pop();

        for(auto &neigh: mp[node]){

            if(!visited[neigh]){

                visited[neigh] = 1;

                q.push({neigh, node});

                path.push_back(neigh);

                break;

            }

            else{

                if(neigh == parent) continue;

                return;

            }

        }

    }

}

void solve(){

    unordered_map<int,set<int>>mp;

    int n, x, y;

    cin >> n >> x >> y;

    for(int i = 1; i <= n; ++i){

        int f1 = i + 1, f2 = i - 1;

        if(f1 == n + 1) f1 = 1;

        if(f2 == 0) f2 = n;

        mp[i].insert(f1);

        mp[i].insert(f2);

    }

    mp[x].insert(y);mp[y].insert(x);

    bool exist = false;

    vector<int>path1, path2;

    for(int i = 1; i <= n; ++i){

        if(mp[i].size() == 3){

            path1.push_back(i);

            path2.push_back(i);

            exist = true;

            break;

        }

    }

    if(!exist){

        if(n % 2 == 0){

            for(int i = 1; i <= n; ++i){

                cout << (i % 2 == 1 ? 0 : 1);

            }

        }

        else{

            for(int i = 1; i <= 3; ++i){

                cout << i - 1 << " ";

            }

            for(int i = 4; i <= n; ++i){

                cout << (i % 2 == 0) << " ";

            }

        }

        cout << "\n";

        return;

    }

    //debug(path1, path2);

    vector<int>visited(n + 1, 0);

    int endnode = -1;

    getpath(n, mp, path1, visited);

    int nc1 = path2[0] + 1, nc2 = path2[0] - 1;

    if(nc1 == n + 1) nc1 = 1;

    if(nc2 == 0) nc2 = n;

    if(!visited[nc2]){

        for(int i = n; i >= 1; --i){

            if(visited[i]) continue;

            else{

                path2.push_back(i);

            }

        }

    }

    else{

        for(int i = 1; i <= n; ++i){

            if(visited[i]) continue;

            else{

                path2.push_back(i);

            }

        }

    }

    //debug(path1);

    path2.push_back(path1.back());

    //debug(path2);

    vector<int>ans(n + 1, -1);

    if(path1.size() % 2 == 1 and path2.size() % 2 == 1){

        ans[path1[0]] = 2;

        int i = 1;

        while(i < path1.size() or i < path2.size()){

            if(i < path1.size()){

                ans[path1[i]] = i % 2;

            }

            if(i < path2.size()){

                ans[path2[i]] = i % 2;

            }

            ++i;

        }

    }

    else if(path1.size() % 2 == 1){

        ans[path1[0]] = 0;

        ans[path1[1]] = 2;

        ans[path1[2]] = 1;

        for(int i = 3; i < path1.size(); ++i){

            if(i & 1) ans[path1[i]] = 0;

            else ans[path1[i]] = 1;

        }

        for(int i = 0; i < path2.size(); ++i){

            if(ans[path2[i]] != -1) continue;

            //debug(path2[i]);

            ans[path2[i]] = i % 2;

        }

    }

    else if(path2.size() % 2 == 1){

        ans[path2[0]] = 0;

        ans[path2[1]] = 2;

        ans[path2[2]] = 1;

        for(int i = 3; i < path2.size(); ++i){

            if(i & 1) ans[path2[i]] = 0;

            else ans[path2[i]] = 1;

        }

        for(int i = 0; i < path1.size(); ++i){

            if(ans[path1[i]] != -1) continue;

            ans[path1[i]] = i % 2;

        }

    }

    else{

        for(int i = 1; i <= n; ++i){

            ans[i] = (i % 2 == 0);

        }

    }

    for(int i = 1; i <= n; ++i){

        cout << ans[i] << " ";

    }

    cout << "\n";

}

int main() {

    FASTIO();

    int t; t = 1;

    cin >> t;

    while(t--){

        solve();

    }

}

Answer: 1


#include<bits/stdc++.h>

using namespace std;

#define int long long

#define pi 3.1415926

#define pb(e) push_back(e)

#define all(x) x.begin(),x.end()

#define cin(v) for(auto &i:v){cin>>i;}

#define sv(a) sort(a.begin(),a.end())

#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL));

#define forn(a, c) for (int (a) = 0; (a) < (c); (a)++)

#define vi vector<int>

#define vii vector<vector<int>>

#define vc vector<char>

#define vcc vector<vector<char>>

void print(vector<int> v) {

for (auto i : v) cout << i << ' ';

cout << endl;}

int binpow(int a,int b){

int res=1;

while(b>0){

if(b&1)

res*=a;

a*=a;

b>>=1;}

return res;}

void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    x--;y--;

    vi ans(n);

    forn(i,n) ans[(x+i)%n]=i%2;

    if(n%2||(x-y)%2==0)

        ans[x]=2;

    print(ans);

}

signed main(){

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

}

#include<bits/stdc++.h>

using namespace std;

#define int long long

#define pi 3.1415926

#define pb(e) push_back(e)

#define all(x) x.begin(),x.end()

#define cin(v) for(auto &i:v){cin>>i;}

#define sv(a) sort(a.begin(),a.end())

#define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL));

#define forn(a, c) for (int (a) = 0; (a) < (c); (a)++)

#define vi vector<int>

#define vii vector<vector<int>>

#define vc vector<char>

#define vcc vector<vector<char>>

void print(vector<int> v) {

for (auto i : v) cout << i << ' ';

cout << endl;}

int binpow(int a,int b){

int res=1;

while(b>0){

if(b&1)

res*=a;

a*=a;

b>>=1;}

return res;}

int mex(vi f,vi ans) {

    set<int> v;

    forn(i,f.size()) {

        v.insert(ans[f[i]]);

    }

    int mex=0;

    for(auto i:v) if(i==mex) mex++;

    return mex;

}

void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    vi ans(n,1e9);

    vii f(n);

    forn(i,n) {

        f[i].pb((i==0)?n-1:i-1);

        f[i].pb((i==n-1)?0:i+1);

    }

    x--;y--;

    f[x].pb(y);

    f[y].pb(x);

    forn(i,n) {

        ans[i]=mex(f[i],ans);

    }

    print(ans);

}

signed main(){

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

}

Answer: 1


/*<------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------

----------------------MADE--BY--VB-----------------------------------------------------

---------------------------------------------------------------------------------------

------------------------------------------------------------------------------------>*/

#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;

// ifstream  i_data("mixmilk.in");

// ofstream  o_data("mixmilk.out");

// #define cin  i_data

// #define cout o_data

/*<--------------------------------DATA--STRUCTURES----------------------------------->*/

#define ll long long

#define pii pair<int, int>

#define pll pair<long long, long long>

#define vi vector<int>

#define vll vector<long long>

#define mii map<int, int>

#define mll map<long long, long long>

#define si set<int>

#define sc set<char>

#define moj_karvani                   \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL);                    \

    cout.tie(NULL)

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// only less behave as set

// less_equal as multiset

// we can replace less with greater for descending order

/*<--------------------------------FUNCTIONS------------------------------------------->*/

string itob(int num)

{

    if (num == 0)

        return "0";

    string binaryString;

    while (num > 0)

    {

        binaryString = (num % 2 == 0 ? "0" : "1") + binaryString;

        num /= 2;

    }

    return binaryString;

}

int btoi(const string &binaryString) { return stoi(binaryString, nullptr, 2); }

void print_binary(int num)

{

    for (int i = 10; i >= 0; i--)

    {

        cout << ((num >> i) & 1);

    }

    cout << endl;

}

string to_upper(string a)

{

    for (int i = 0; i < (int)a.size(); ++i)

        if (a[i] >= 'a' && a[i] <= 'z')

            a[i] -= 'a' - 'A';

    return a;

}

string to_lower(string a)

{

    for (int i = 0; i < (int)a.size(); ++i)

        if (a[i] >= 'A' && a[i] <= 'Z')

            a[i] += 'a' - 'A';

    return a;

}

bool comp(const pair<int, int> &a, const pair<int, int> &b)

{

    if (a.first == b.first)

    {

        return a.second < b.second;

    }

    return a.first < b.first;

};

vector<int> find_intersection(int a, int b, int c, int d, int p, int q, int r, int s)

{

    vector<int> v;

    int l = max(a, p);

    int m = max(b, q);

    int n = min(c, r);

    int o = min(d, s);

    int x = n - l;

    int y = o - m;

    if (x < 0 || y < 0)

    {

        return v;

    }

    v.push_back(l);

    v.push_back(m);

    v.push_back(n);

    v.push_back(o);

    return v;

}

/*<-----------------------------BASIC--MATH----------------------------------------->*/

const ll M = 1e9 + 7, N = 1e5 + 5;

ll gcd(ll a, ll b)

{

    if (b == 0)

        return a;

    return gcd(b, a % b);

}

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

// ll power(ll a,ll b){if(b==0) return 1;ll res=power(a,b/2);if(b&1){return a*res*res;}else{return res*res;}}

ll power(ll a, ll b)

{

    ll ans = 1;

    while (b)

    {

        if (b & 1)

        {

            ans = ans * a;

        }

        a = a * a;

        b >>= 1;

    }

    return ans;

}

// ll isPrime(ll a){ if (a != 2 && a % 2 == 0 || a < 2) return 0;  for(ll i = 3; i * i <= a; i += 2) if(a % i == 0) return 0; return 1;}

bool isPrime(int number)

{

    if (number <= 1)

        return false;

    if (number == 2)

        return true;

    if (number % 2 == 0)

        return false;

    int boundary = (int)floor(sqrt(number));

    for (int i = 3; i <= boundary; i += 2)

        if (number % i == 0)

            return false;

    return true;

}

/*<---------------------------------Solve--here-------------------------------------------->*/

void solve()

{

    ll n, x, y;

    cin >> n >> x >> y;

    vector<ll> ans(n + 1);

    int b = 0;

    int f=0;

    for (int i = x; i <= y; i++)

    {

        if (b == 0)

        {

            ans[i] = 0;

            b = 1;

        }

        else

        {

            ans[i] = 1;

            b = 0;

        }

    }

    if ((abs(x - y) + 1) & 1)

    {

        f=1;

        ans[y] = 2;

    };

    ll p = n - y + 1LL + x;

    if (p & 1)

    {

        b = 1;

    }

    else

    {

        b = 0;

    }

    if(f==0 && p&1){

        b=0;

    }

    for (int i = y + 1; i <= n; i++)

    {

        if (b == 0)

        {

            ans[i] = 0;

            b = 1;

        }

        else

        {

            ans[i] = 1;

            b = 0;

        }

    }

    for (int i = 1; i < x; i++)

    {

        if (b == 0)

        {

            ans[i] = 0;

            b = 1;

        }

        else

        {

            ans[i] = 1;

            b = 0;

        }

    }

    if(x==1){

        x=n;

    }

    else{

        x--;

    }

    if(f==0 && p&1){

        ans[x]=2;

    }

    for(int i=1;i<=n;i++){

        cout<<ans[i]<<" ";

    }

    cout<<endl;

}

/*<-------------------------------Main--Function------------------------------------------>*/

int main()

{

    moj_karvani;

    int t = 1;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

/*<-------------------------------Thank--You----------------------------------------------->*/

/*<------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------

----------------------MADE--BY--VB-----------------------------------------------------

---------------------------------------------------------------------------------------

------------------------------------------------------------------------------------>*/

#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;

// ifstream  i_data("mixmilk.in");

// ofstream  o_data("mixmilk.out");

// #define cin  i_data

// #define cout o_data

/*<--------------------------------DATA--STRUCTURES----------------------------------->*/

#define ll long long

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define vi vector<int>

#define vll vector<long long>

#define mii map<int, int>

#define mll map<long long, long long>

#define si set<int>

#define sc set<char>

#define moj_karvani  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// only less behave as set

//less_equal as multiset

//we can replace less with greater for descending order

/*<--------------------------------FUNCTIONS------------------------------------------->*/

string itob(int num) {if (num == 0) return "0";string binaryString;while (num > 0) {binaryString = (num % 2 == 0 ? "0" : "1") + binaryString;num /= 2;}return binaryString;}

int btoi(const string& binaryString) {return stoi(binaryString, nullptr, 2);}

void print_binary(int num){for(int i=10;i>=0;i--){cout<<((num>>i) & 1);}cout<<endl;}

string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }

string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }

bool comp(const pair<int, int>& a, const pair<int, int>& b) {if (a.first == b.first) {return a.second < b.second; }return a.first <b.first; };

vector<int> find_intersection(int a,int b,int c,int d,int p,int q,int r ,int s){vector<int>v;int l=max(a,p);int m=max(b,q);int n=min(c,r);int o=min(d,s);int x=n-l;int y=o-m;if(x<0 || y<0){return v;}v.push_back(l);v.push_back(m);v.push_back(n);v.push_back(o);return v;}

/*<-----------------------------BASIC--MATH----------------------------------------->*/

const ll M=1e9+7,N=1e5+5;

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

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

//ll power(ll a,ll b){if(b==0) return 1;ll res=power(a,b/2);if(b&1){return a*res*res;}else{return res*res;}}

ll power(ll a, ll b){ll ans=1;while(b){if(b&1){ans=ans*a;}a=a*a;b>>=1;}return ans;}

//ll isPrime(ll a){ if (a != 2 && a % 2 == 0 || a < 2) return 0;  for(ll i = 3; i * i <= a; i += 2) if(a % i == 0) return 0; return 1;}

bool isPrime(int number){if (number <= 1)return false;if (number == 2)return true;if (number % 2 == 0) return false;int boundary = (int)floor(sqrt(number));for (int i = 3; i <= boundary; i += 2)if (number % i == 0)return false;return true;}

/*<---------------------------------Solve--here-------------------------------------------->*/

void solve(){

    ll n,x,y;

    cin>>n>>x>>y;

    vector<ll> ans;

    for(int i=0;i<n;i++){

        if(i&1)ans.push_back(1);

        else ans.push_back(0);

    }

    if(n & 1 || (x-y)%2==0){ans[x]=2;}

    for(auto it:ans){cout<<it<<" ";}

    cout<<endl;

}

/*<-------------------------------Main--Function------------------------------------------>*/

int main(){

	moj_karvani;

	int t=1;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

/*<-------------------------------Thank--You----------------------------------------------->*/

Answer: 1


#include<bits/stdc++.h>

using namespace std;

#define rep(i, l, n) for(int i = (int)(l); i < (int)(n); i++)

#define ll long long

vector<int> solve() {

    int n; cin >> n;

    int x, y; cin >> x >> y;

    x--; y--;

    vector<int> ans(n, 0);

    rep(i, 0, n) ans[i] = i % 2;

    if(n % 2) ans[n - 1] = 2;

    int start = -1;

    rep(i, 0, n) {

        if(ans[i] != ans[(i + y - x) % n]) start = i;

    }

    if(start == -1) {

        ans[0] = 2;

    }

    start = (start - x + n) % n;

    vector<int> real_ans(n);

    rep(i, 0, n) real_ans[i] = ans[(i + start) % n];

    return real_ans;

}

int main() {

    int t; cin >> t;

    while(t--) {

        auto v = solve();

        for(int u : v) cout << u << " ";

        cout << endl;

    }

}

#include<bits/stdc++.h>

using namespace std;

#define rep(i, l, n) for(int i = (int)(l); i < (int)(n); i++)

#define ll long long

vector<int> solve() {

    int n; cin >> n;

    int x, y; cin >> x >> y;

    x--; y--;

    vector<int> ans(n, 0);

    rep(i, 0, n) ans[i] = i % 2;

    if(n % 2) ans[n - 1] = 2;

    int start = -1;

    rep(i, 0, n) {

        if(ans[i] != ans[(i + y - x) % n]) start = i;

    }

    if(start == -1) {

        ans[0] = 2;

        start = 0;

    }

    start = (start - x + n) % n;

    vector<int> real_ans(n);

    rep(i, 0, n) real_ans[i] = ans[(i + start) % n];

    return real_ans;

}

int main() {

    int t; cin >> t;

    while(t--) {

        auto v = solve();

        for(int u : v) cout << u << " ";

        cout << endl;

    }

}

Answer: 2


#include <bits/stdc++.h>

typedef long long ll;

#define MII map<int, int>

#define UMII unordered_map<int, int>

#define F first

#define S second

#define PB push_back

#define MP make_pair

#define vi vector<int>

#define vvi vector<vi>

#define qi queue<int>

#define si stack<int>

#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;

    cin >> t;

    while(t--){

        int n, x, y;

        cin >> n >> x >> y;

        if(x > y) swap(x, y);

        x--;

        y--;

        vector<int> arr(n);

        for(int i = 0; i < n; i++){

            arr[(x+i) % n] = i % 2;

        }

        if((y - x) % 2 == 0) arr[x] = 2;

        for(int i = 0; i < n; i++){

            cout << arr[i] << " ";

        }

        cout << endl;

    }

    return 0;

}

#include <bits/stdc++.h>

typedef long long ll;

#define MII map<int, int>

#define UMII unordered_map<int, int>

#define F first

#define S second

#define PB push_back

#define MP make_pair

#define vi vector<int>

#define vvi vector<vi>

#define qi queue<int>

#define si stack<int>

#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;

    cin >> t;

    while(t--){

        int n, x, y;

        cin >> n >> x >> y;

        if(x > y) swap(x, y);

        x--;

        y--;

        vector<int> arr(n);

        for(int i = 0; i < n; i++){

            arr[(x+i) % n] = i % 2;

        }

        if((y - x) % 2 == 0 || (x+n-y) % 2 == 0) arr[x] = 2;

        for(int i = 0; i < n; i++){

            cout << arr[i] << " ";

        }

        cout << endl;

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;

int main() {

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

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		--x, --y;

		vector<ll> a(n);

		if (n & 1) {

			a[x] = 2;

			for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

		}

		else {

			if ((x ^ y) & 1) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;

int main() {

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

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		--x, --y;

		vector<ll> a(n);

		if (n & 1) {

			a[x] = 2;

			for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

		}

		else {

			if (x != y) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}

Answer: 1


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

#define int long long

#define endl '\n'

#define IOS ios::sync_with_stdio(0),cin.tie(0);

#define all(x) x.begin(),x.end()

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int>

#define vi vector<int>

#define vc vector<char>

#define si set<int>

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	x--,y--;

	vi a(n);

	for (int i=0,j=0;i<n;i++){

		a[(x+i)%n]=j;

		j=1-j;

	}

	if(n&1||(y-x)%2==0){

		a[x]=2;

	}

	for (auto i : a){

		cout<<i<<" ";

	}

	cout<<endl;

}

signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

#define int long long

#define endl '\n'

#define IOS ios::sync_with_stdio(0),cin.tie(0);

#define all(x) x.begin(),x.end()

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int>

#define vi vector<int>

#define vc vector<char>

#define si set<int>

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	vi a(n+1);

	if(n%2==0){

		for(int i=1,j=0;i<=n;i++){

			a[i]=j;

			j=1-j;

		}

	}

	else {

		for (int i=1,j=0;i<n;i++){

			a[i]=j;

			j=1-j;

		}

		a[n]=2;

	}

	if(a[x]==a[y]){

		if(x!=1){

			a[x]=2;

		}

		else {

			a[y]=2;

		}

	}

	for (int i=1;i<=n;i++){

		cout<<a[i]<<' ';

	}

	cout<<endl;

}

signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}

Answer: 1


/**

you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )

**/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/hash_policy.hpp>

// #pragma GCC optimize("Ofast")

// #pragma GCC target("avx,avx2,fma")

// #pragma GCC optimization ("unroint-loops")

// #include "robin_hood.h"

using namespace __gnu_pbds;

using namespace std;

typedef long long ll;

typedef unsigned long long ul;

typedef tree<pair <ll, ll>, null_type, greater<pair <ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define endl "\n"

const int mod = 998244353;

const int dx[] = {1, -1, 0, 0};

const int dy[] = {0, 0, 1, -1};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 5;

void Solve() {

    int n, x, y; cin >> n >> x >> y;

    vector <int> ans(n + 1);

    ans[x] = (n - y + x - 1) % 2 || (y - x - 1) % 2 ? 2 : 0;

    ans[y] = 1;

    for (int i = y + 1; i <= n; i++) ans[i] = ans[i - 1] == 0 ? 1 : 0;

    for (int i = 1; i < x; i++) ans[i] = ans[i > 1 ? i - 1 : n] == 0 ? 1 : 0;

    for (int i = y - 1; i > x; i--) ans[i] = ans[i + 1] == 0 ? 1 : 0;

    for (int i = 1; i <= n; i++) cout << ans[i] << " ";

    cout << endl;

}

signed main() {

    fast();

    int t = 1; cin >> t;

    while (t--) Solve();

}

/**

you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )

**/

/**

you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )

**/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/hash_policy.hpp>

// #pragma GCC optimize("Ofast")

// #pragma GCC target("avx,avx2,fma")

// #pragma GCC optimization ("unroint-loops")

// #include "robin_hood.h"

using namespace __gnu_pbds;

using namespace std;

typedef long long ll;

typedef unsigned long long ul;

typedef tree<pair <ll, ll>, null_type, greater<pair <ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define endl "\n"

const int mod = 998244353;

const int dx[] = {1, -1, 0, 0};

const int dy[] = {0, 0, 1, -1};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 5;

void Solve() {

    int n, x, y; cin >> n >> x >> y;

    vector <int> ans(n + 1);

    ans[x] = 2;

    ans[y] = 1;

    for (int i = y + 1; i <= n; i++) ans[i] = ans[i - 1] == 0 ? 1 : 0;

    for (int i = 1; i < x; i++) ans[i] = ans[i > 1 ? i - 1 : n] == 0 ? 1 : 0;

    for (int i = y - 1; i > x; i--) ans[i] = ans[i + 1] == 0 ? 1 : 0;

    for (int i = 1; i <= n; i++) cout << ans[i] << " ";

    cout << endl;

}

signed main() {

    fast();

    int t = 1; cin >> t;

    while (t--) Solve();

}

/**

you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )

**/

Answer: 1


#include <bits/stdc++.h>

using namespace std;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

        for(int i=x;i<n+x;i++)

        {

            a[i%n]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

        for(int i=0;i<n;i++)

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

        for(int i=x;i<n+x;i++)

        {

            a[i%n]=i%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

        for(int i=0;i<n;i++)

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,x,y,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m>>x>>y;

      x--; y--;

      vector<ll>v(m);

      for(int i=0;i<m;i++)

      v[(x+i)%m]=i%2;

      if(m%2 || (x-y)%2==0)

      v[x]=2;

      for(auto k : v)

      cout<<k<<' ';

      cout<<endl;

    }

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,x,ysay1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m>>x>>y;

      x--; y--;

      vector<ll>v(m);

      for(int i=0;i<m;i++)

      v[(x+i)%m]=i%2;

      if(m%2 || (x-y)%2==0)

      ans[x]=2;

      for(auto k : ans)

      cout<<k<<' ';

      cout<<endl;

    }

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e6 + 7;

ll r[N];

int h[N], e[N], ne[N], idx;

void add(int a, int b)

{

    e[idx] = b, ne[idx] = h[a], h[a] = idx++;

}

void dfs(int x)

{

    if (r[x] >= 0)

    {

        return;

    }

    set<ll> s;

    for (int i = h[x]; i != -1; i = ne[i])

    {

        int to = e[i];

        if (r[to] >= 0)

        {

            s.insert(r[to]);

        }

    }

    for (int i = 0; i <= 10; i++)

    {

        if (s.count(i) == 0)

        {

            r[x] = i;

            break;

        }

    }

    for (int i = h[x]; i != -1; i = ne[i])

    {

        int to = e[i];

        dfs(to);

    }

}

void solve()

{

    ll n, x, y;

    cin >> n >> x >> y;

    idx = 0;

    for (int i = 1; i <= n; i++)

    {

        r[i] = -1;

        h[i] = -1;

    }

    for (int i = 2; i <= n; i++)

    {

        add(i - 1, i);

        add(i, i - 1);

    }

    add(1, n);

    add(n, 1);

    add(x, y);

    add(y, x);

    r[y] = 1;

    dfs(x);

    for (int i = 1; i <= n; i++)

    {

        cout << r[i] << ' ';

    }

    cout << '\n';

}

int main()

{

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

    int T;

    cin >> T;

    while (T--)

    {

        solve();

    }

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5 + 7;

ll r[N];

int h[N], e[N], ne[N], idx;

void add(int a, int b)

{

    e[idx] = b, ne[idx] = h[a], h[a] = idx++;

}

void dfs(int x)

{

    if (r[x] >= 0)

    {

        return;

    }

    set<ll> s;

    for (int i = h[x]; i != -1; i = ne[i])

    {

        int to = e[i];

        if (r[to] >= 0)

        {

            s.insert(r[to]);

        }

    }

    for (int i = 0; i <= 10; i++)

    {

        if (s.count(i) == 0)

        {

            r[x] = i;

            break;

        }

    }

    for (int i = h[x]; i != -1; i = ne[i])

    {

        int to = e[i];

        dfs(to);

    }

}

void solve()

{

    ll n, x, y;

    cin >> n >> x >> y;

    idx = 0;

    for (int i = 1; i <= n; i++)

    {

        r[i] = -1;

        h[i] = -1;

    }

    for (int i = 2; i <= n; i++)

    {

        add(i - 1, i);

        add(i, i - 1);

    }

    add(1, n);

    add(n, 1);

    add(x, y);

    add(y, x);

    r[y] = 1;

    dfs(x);

    for (int i = 1; i <= n; i++)

    {

        cout << r[i] << ' ';

    }

    cout << '\n';

}

int main()

{

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

    int T;

    cin >> T;

    while (T--)

    {

        solve();

    }

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

int main()

{

	int t;

	cin>>t;

	while(t--){

		int n,x,y;

		cin>>n>>x>>y;

		vector<int>ans(n);

		for(int i=0; i<n; i++){

			ans[(i+x)%n]=i%2;

		}

		if(n&1 || (y-x)%2==0){

			ans[x]=2;

		}

		for(int i=0; i<n; i++){

			cout<<ans[i]<<" ";

		}

	cout<<endl;

	}

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main()

{

	int t;

	cin>>t;

	while(t--){

		int n,x,y;

		cin>>n>>x>>y;

		x--;y--;

		vector<int>ans(n);

		for(int i=0; i<n; i++){

			ans[(i+x)%n]=i%2;

		}

		if(n%2 || (x-y)%2==0){

			ans[x]=2;

		}

		for(int i=0; i<n; i++){

			cout<<ans[i]<<" ";

		}

	cout<<endl;

	}

	return 0;

}

Answer: 2


Answer: 1


#include <bits/stdc++.h>

//#include <atcoder/all>

using namespace std;

//using namespace atcoder;

//using mint = modint998244353;

//long long型=int64_tという認識で大丈夫です。

#define ll long long

#define ull unsigned long long

#define vec vector

#define vi vector<int>

#define vll vector<ll>

#define pq priority_queue

#define pb push_back

#define rep(i, l, r) for(int i=(int)(l); i<(int)(r); i++)

#define ld long double

const ll INF = 1e9;

const ll inf = 9e18;

struct Edge {

    int to;

    ll cost;

};

struct SEdge {

    int to;

    pair<ll, ll> cost;

};

template<class T>

using spq = priority_queue<T, vec<T>, greater<T>>;

const vector<int> di = {-1, 0, 1, 1, 0, -1}, dj = {0, 1, 1, 0, -1, -1};

template<class T>

bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}

template<class T>

bool chmax(T& a, T b) {

    if(a < b) {

        a = b;

        return true;

    }

    return false;

}

using S = ll;

S op(S a, S b) {return a + b;}

S e() {return 0;}

int main() {

    int t; cin >> t;

    rep(i, 0, t) {

        int n, x, y; cin >> n >> x >> y; x--; y--;

        vi ans(n, 0);

        rep(j, 0, n) {

            ans[j] = j % 2;

        }

        if(n % 2 == 1) ans[n - 1] = 2;

        if(ans[x] == ans[y]) {

            ans[max(x, y)] = 2;

            if(y == n - 2 && ans[n - 1] == 2) {ans[n - 1] = 1;}

            if(y == n - 3 && ans[n - 1] == 2) {ans[n - 2] = 0; ans[n - 1] = 1;}

        }

        rep(j, 0, n) cout << ans[j] << " ";

        cout << endl;

    }

}

#include <bits/stdc++.h>

//#include <atcoder/all>

using namespace std;

//using namespace atcoder;

//using mint = modint998244353;

//long long型=int64_tという認識で大丈夫です。

#define ll long long

#define ull unsigned long long

#define vec vector

#define vi vector<int>

#define vll vector<ll>

#define pq priority_queue

#define pb push_back

#define rep(i, l, r) for(int i=(int)(l); i<(int)(r); i++)

#define ld long double

const ll INF = 1e9;

const ll inf = 9e18;

struct Edge {

    int to;

    ll cost;

};

struct SEdge {

    int to;

    pair<ll, ll> cost;

};

template<class T>

using spq = priority_queue<T, vec<T>, greater<T>>;

const vector<int> di = {-1, 0, 1, 1, 0, -1}, dj = {0, 1, 1, 0, -1, -1};

template<class T>

bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}

template<class T>

bool chmax(T& a, T b) {

    if(a < b) {

        a = b;

        return true;

    }

    return false;

}

using S = ll;

S op(S a, S b) {return a + b;}

S e() {return 0;}

int main() {

    int t; cin >> t;

    rep(i, 0, t) {

        int n, x, y; cin >> n >> x >> y; x--; y--;

        vi ans(n, 0);

        rep(j, 0, n) {

            ans[j] = j % 2;

        }

        if(n % 2 == 1) ans[n - 1] = 2;

        if(ans[x] == ans[y]) {

            ans[max(x, y)] = 2;

            if(y == n - 2 && ans[n - 1] == 2) {ans[n - 2] = 3;}

            if(y == n - 3 && ans[n - 1] == 2) {ans[n - 2] = 0; ans[n - 1] = 1;}

        }

        rep(j, 0, n) cout << ans[j] << " ";

        cout << endl;

    }

}

Answer: 1


#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/assoc_container.hpp>

#include <chrono>

#define pb push_back

#define INF 0x3f3f3f3f

#define LINF 0x3f3f3f3f3f3f3f3f

#define endl '\n'

#define ll long long

#define f first

#define fin cin

#define fout cout

#define s second

#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)

#define debug(x) cout << "DEBUG " << x << endl

#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl

#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl

#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl

#define all(x) x.begin(), x.end()

#define left esquerda

#define lb lower_bound

#define right direita

using namespace std;

using namespace __gnu_pbds;

void setIO(string s) {

ios_base::sync_with_stdio(0); cin.tie(0);

freopen((s+".in").c_str(),"r",stdin);

freopen((s+".out").c_str( ),"w",stdout);

}

typedef pair<int, ll> pii;

typedef vector<vector<char>> mat;

typedef pair<int, string> pis;

const ll mod = 1e9 + 7, MAXN = 2e5 + 5;

typedef vector<int> vi;

typedef pair<int, pair<int, int>> piii;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();

struct chash {

    int operator()(int x) const { return x ^ RANDOM; }

};

void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--, y--;

    vector<int> v(n);

    v[n - 1] = 1;

    v[1] = 1;

    if(!x && y != 1 && y != n - 1)

        v[y] = 1;

    for(int i = 1; i < n; i++) {

        if(v[i] == v[i + 1])

            v[i + 1]++;

        if(x == i && v[x] == v[y])

            v[y]++;

    }

    for(int &i : v)

        cout << i << " ";

    cout << endl;

}

int32_t main() {

    int ct = 1;

    cin >> ct;

    while(ct--)

        solve();

}

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/assoc_container.hpp>

#include <chrono>

#define pb push_back

#define INF 0x3f3f3f3f

#define LINF 0x3f3f3f3f3f3f3f3f

#define endl '\n'

#define ll long long

#define f first

#define fin cin

#define fout cout

#define s second

#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)

#define debug(x) cout << "DEBUG " << x << endl

#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl

#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl

#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl

#define all(x) x.begin(), x.end()

#define left esquerda

#define lb lower_bound

#define right direita

using namespace std;

using namespace __gnu_pbds;

void setIO(string s) {

ios_base::sync_with_stdio(0); cin.tie(0);

freopen((s+".in").c_str(),"r",stdin);

freopen((s+".out").c_str( ),"w",stdout);

}

typedef pair<int, ll> pii;

typedef vector<vector<char>> mat;

typedef pair<int, string> pis;

const ll mod = 1e9 + 7, MAXN = 2e5 + 5;

typedef vector<int> vi;

typedef pair<int, pair<int, int>> piii;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();

struct chash {

    int operator()(int x) const { return x ^ RANDOM; }

};

void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--, y--;

    vector<int> v(n);

    priority_queue<pii, vector<pii>, greater<pii>> fila;

    for(int i = 0; i < n; i++)

        fila.push({0, i});

    while(!fila.empty()) {

        pii aux = fila.top();

        fila.pop();

        if(v[aux.s] != aux.f)

            continue;

        int viz = (aux.s ? aux.s - 1 : n - 1);

        int viz2 = (aux.s + 1 < n ? aux.s + 1 : 0);

        vector<int> vl = {viz, viz2};

        if(aux.s == x)

            vl.pb(y);

        if(aux.s == y)

            vl.pb(x);

        for(int &i : vl)

            if(aux.f == v[i]) {

                fila.push({aux.f + 1, i});

                v[i] = aux.f + 1;

            }

    }

    for(int &i : v)

        cout << i << " ";

    cout << endl;

}

int32_t main() {

    int ct = 1;

    cin >> ct;

    while(ct--)

        solve();

}

Answer: 2


#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

        for(int i=1;i<=n-1;i++){

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    for(int i=1;i<=n;i+=2)a[i]=1,a[i+1]=0;

    if(x+1==y||(y+1==x)||(x==1&&y==n)||(x==n&&y==1)){

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    if(a[x]==a[y]){

        a[x]=2;

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    a[x]=2;int xx=x;

    int fl=0;

    while(1){

        x++;if(x==n+1)x=1;

        if(x==y)break;

        if(fl==0)a[x]=0;

        if(fl==1)a[x]=2;

        if(fl>=2)a[x]=(fl-1)&1;

        fl++;

    }

    fl=0;x=xx;

    while(1){

        x--;if(x==0)x=n;

        if(x==y)break;

        a[x]=(fl-1)&1;

        fl++;

    }

    a[y]=1;

    for(int i=1;i<=n;i++)cout<<a[i]<<' ';

    cout<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

#include<bits/stdc++.h>

#define pii pair<int,int>

#define fi first

#define se second

#define ll long long

#define int long long

#define endl '\n'

#define ull unsigned long long

using namespace std;

const int N=2e5+5;

int a[N],n,x,y;

void work(){

    cin>>n>>x>>y;

    if(n&1){

        a[x]=2;

        for(int i=1;i<=n-1;i++){

            x++;if(x==n+1)x=1;

            a[x]=(i&1);

        }

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    for(int i=1;i<=n;i+=2)a[i]=1,a[i+1]=0;

    if(x+1==y||(y+1==x)||(x==1&&y==n)||(x==n&&y==1)){

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    if(a[x]==a[y]){

        a[x]=2;

        for(int i=1;i<=n;i++)cout<<a[i]<<' ';

        cout<<endl;

        return;

    }

    a[x]=2;int xx=x;

    int fl=0;

    while(1){

        x++;if(x==n+1)x=1;

        if(x==y)break;

        if(fl==0)a[x]=0;

        if(fl==1)a[x]=2;

        if(fl>=2)a[x]=(fl-1)&1;

        fl++;

    }

    fl=0;x=xx;

    while(1){

        x--;if(x==0)x=n;

        if(x==y)break;

        a[x]=(fl-1)&1;

        fl++;

    }

    for(int i=1;i<=n;i++)cout<<a[i]<<' ';

    cout<<endl;

    return;

}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int T=1;

    cin>>T;

    while(T--)work();

    return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define int long long

void build(vector<int> &segtree, vector<int> &arr, int v, int l, int r) {

    if (l == r) {

        segtree[v]=arr[l];

    } else {

        int mid = (l + r) / 2;

        build(segtree, arr, 2 * v, l, mid);

        build(segtree, arr, 2 * v + 1, mid + 1, r);

        segtree[v] = gcd(segtree[2 * v], segtree[2 * v + 1]);

    }

}

int query(vector<int> &segtree, vector<int> &arr, int v, int l, int r, int l1, int r1) {

    if (r1 < l || r < l1) {

        return 0;

    } else if (l >= l1 && r <= r1) {

        return segtree[v];

    } else {

        int mid = (l + r) / 2;

        int a = query(segtree, arr, 2 * v, l, mid, l1, r1);

        int b = query(segtree, arr, 2 * v + 1, mid + 1, r, l1, r1);

        return gcd(a, b);

    }

}

int32_t main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

      int n,x,y;

      cin>>n>>x>>y;

      x--; y--;

      vector<int> arr(n);

      for(int i=0;i<n;++i)

      {

        if(i%2==0)

            arr[i]=0;

        else arr[i]=1;

      }

      if(n%2==1)

      {

        arr[n-1]=2;

      }

      if(arr[x]==arr[y])

      {

        arr[y]=2;

        if(arr[x]==0)

        {

            // cout<<y+1<<endl;

            for(int i=y+1;i<n;++i)

            {

                if((y+1-i) % 2==0)

                    arr[i]=0;

                else

                    arr[i]=1;

            }

            if(arr[n-1]==0 )

            {

                if(arr[n-2]==1)

                    arr[n-1]=2;

                else if(arr[n-2]==2)

                    arr[n-1]=1;

            }

        }

      }

       for(auto x:arr)

       {

        cout<<x<<" ";

       }

       cout<<endl;

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define int long long

void build(vector<int> &segtree, vector<int> &arr, int v, int l, int r) {

    if (l == r) {

        segtree[v]=arr[l];

    } else {

        int mid = (l + r) / 2;

        build(segtree, arr, 2 * v, l, mid);

        build(segtree, arr, 2 * v + 1, mid + 1, r);

        segtree[v] = gcd(segtree[2 * v], segtree[2 * v + 1]);

    }

}

int query(vector<int> &segtree, vector<int> &arr, int v, int l, int r, int l1, int r1) {

    if (r1 < l || r < l1) {

        return 0;

    } else if (l >= l1 && r <= r1) {

        return segtree[v];

    } else {

        int mid = (l + r) / 2;

        int a = query(segtree, arr, 2 * v, l, mid, l1, r1);

        int b = query(segtree, arr, 2 * v + 1, mid + 1, r, l1, r1);

        return gcd(a, b);

    }

}

int32_t main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

      int n,x,y;

      cin>>n>>x>>y;

      x--; y--;

      vector<int> arr(n);

      for(int i=0;i<n;++i)

      {

        if(i%2==0)

            arr[i]=0;

        else arr[i]=1;

      }

      if(n%2==1)

      {

        arr[n-1]=2;

      }

      if(arr[x]==arr[y])

      {

        arr[y]=2;

        if(arr[x]==0)

        {

            // cout<<y+1<<endl;

            for(int i=y+1;i<n;++i)

            {

                if((y+1-i) % 2==0)

                    arr[i]=0;

                else

                    arr[i]=1;

            }

            if(arr[n-1]==0 )

            {

                if(arr[n-2]==1)

                    arr[n-1]=2;

                else if(arr[n-2]==2)

                    arr[n-1]=1;

            }

        }

        else

        {

            if(arr[n-2]==2 && arr[n-1]==2)

                arr[n-1]=1;

        }

      }

       for(auto x:arr)

       {

        cout<<x<<" ";

       }

       cout<<endl;

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

int mex(int a,int b){

    int less = min(a,b);

    int more = max(a,b);

    for(int i=0;i<=3;i++){

        if(i!=less && i!=more){

            return i;

        }

    }

}

int main(){

    int tests;

    cin>>tests;

    for(int test=0;test<tests;test++){

        int n,x,y;

        cin>>n>>x>>y;

        vector<int> a;

        if(n%2==0){

            for(int i=0;i<n;i++){

                if(i%2==0){

                    a.push_back(0);

                }

                else{

                    a.push_back(1);

                }

            }

        }

        else{

            for(int i=0;i<n-2;i++){

                if(i%2==0){

                    a.push_back(0);

                }

                else{

                    a.push_back(1);

                }

            }

            a.push_back(2);

            a.push_back(1);

        }

        if(a[x-1] == a[y-1]){

            a[x-1] = 2;

            for(int i=0;i<n-1;i++){

                if(i==(x-1))continue;

                if(i==0){

                    a[i] = mex(a[n-1],a[i+1]);

                }

                else{

                    a[i] = mex(a[i-1],a[i+1]);

                }

            }

        }

        for(int i=0;i<n;i++){

            cout<<a[i]<<" ";

        }

        cout<<endl;

    }

}

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

int mex(int a,int b){

    int less = min(a,b);

    int more = max(a,b);

    for(int i=0;i<=3;i++){

        if(i!=less && i!=more){

            return i;

        }

    }

}

int main(){

    int tests;

    cin>>tests;

    for(int test=0;test<tests;test++){

        int n,x,y;

        cin>>n>>x>>y;

        vector<int> a;

        if(n%2==0){

            for(int i=0;i<n;i++){

                if(i%2==0){

                    a.push_back(0);

                }

                else{

                    a.push_back(1);

                }

            }

        }

        else{

            for(int i=0;i<n-2;i++){

                if(i%2==0){

                    a.push_back(0);

                }

                else{

                    a.push_back(1);

                }

            }

            a.push_back(2);

            a.push_back(1);

        }

        if(a[x-1] == a[y-1]){

            a[x-1] = 2;

            for(int i=0;i<n;i++){

                if(i==(x-1))continue;

                if(i==0){

                    a[i] = mex(a[n-1],a[i+1]);

                }

                else if(i==n-1){

                    a[i] = mex(a[i-1],a[0]);

                }

                else{

                    a[i] = mex(a[i-1],a[i+1]);

                }

            }

            for(int i=0;i<n;i++){

                if(i==(x-1))continue;

                if(i==0){

                    a[i] = mex(a[n-1],a[i+1]);

                }

                else if(i==n-1){

                    a[i] = mex(a[i-1],a[0]);

                }

                else{

                    a[i] = mex(a[i-1],a[i+1]);

                }

            }

        }

        for(int i=0;i<n;i++){

            cout<<a[i]<<" ";

        }

        cout<<endl;

    }

}

Answer: 2


#include <bits/stdc++.h>

#define int long long

#define all(x,y) x.begin()+y,x.end()

using namespace std;

typedef pair<int, int> pii;

typedef array<int,2> arr2;

const int inf = 1e18 + 30;

const int N=1e5+15;

const int mod=1e9+7;

void smin(int&x,int y){x=min(x,y);}

void smax(int&x,int y){x=max(x,y);}

void help(){

    int n,x,y;cin>>n>>x>>y;

    vector<int> vec(n+1);

    for(int i=1;i<=n;i++)

        vec[i]=(i&1?0:1);

    if(n&1)

        for(int i=n;i>=1;i-=2){

            vec[i]=1;

            // if(i-1!=x&&i-1!=y){

                vec[i-1]=2;

                break;

            // }

        }

    set<int> st;

    st.insert(vec[(x-1)<1?n:(x-1)]);

    st.insert(vec[(x+1)>n?1:(x+1)]);

    st.insert(vec[y]);

    int mex=0;

    while(st.count(mex)) mex++;

    vec[x]=mex;

    for(int i=1;i<=n;i++)

        cout<<vec[i]<<" \n"[i==n];

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t=1;

    cin>>t;

    while(t--){

        help();

        // cout<<help()<<"\n";

    }

    return 0;

}

#include <bits/stdc++.h>

#define int long long

#define all(x,y) x.begin()+y,x.end()

using namespace std;

typedef pair<int, int> pii;

typedef array<int,2> arr2;

const int inf = 1e18 + 30;

const int N=1e5+15;

const int mod=1e9+7;

void smin(int&x,int y){x=min(x,y);}

void smax(int&x,int y){x=max(x,y);}

void help(){

    int n,x,y;cin>>n>>x>>y;

    vector<int> vec(n+1);

    if(n&1){

        vec[x]=2; vec[x-1]=1,vec[x+1]=0;

        for(int i=x+2;i<=n;i++)

            vec[i]=vec[i-1]^1;

        for(int i=x-2;i>=1;i--)

            vec[i]=vec[i+1]^1;

    }

    else{

        if(abs(x-y)&1)

            for(int i=1;i<=n;i++)

                vec[i]=vec[i-1]^1;

        else{

            for(int i=x+1;i<=n;i++)

                vec[i]=vec[i-1]^1;

            for(int i=x-1;i>=1;i--)

                vec[i]=vec[i+1]^1;

            vec[y]=2;

        }

    }

    for(int i=1;i<=n;i++)

        cout<<vec[i]<<" \n"[i==n];

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t=1;

    cin>>t;

    while(t--){

        help();

        // cout<<help()<<"\n";

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

#define print_b(ans) cout<<(ans?"YES":"NO")<<endl;

#define print_n(x)        cout<<x<<endl;

#define times(x)          int x;cin>>x;while(x--)

#define debug(x) cout<<#x<<": "<<x<<endl;

typedef long long ll;

void judge(){

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

    #ifndef ONLINE_JUDGE

        freopen("input.txt","r",stdin);

        //freopen("output.txt","w",stdout);

    #endif

}

int main(){

    judge();

    times(x){

        int n,x,y;cin>>n>>x>>y;

        if(x<y)swap(x,y);

        vector<int> ans(n);

        ans[x-1]=1;

        ans[y-1]=0;

        int left=(x-y-1);

        int right=n-(x-y+1);

        if(left%2==0){

            bool test=1;

            for(int i=y;i<x-1;i++){

                ans[i]=test;

                test^=1;

            }

        }

        else{

            bool test=1;

            for(int i=y;i<(y+left/2);i++){

                ans[i]=test;

                test^=1;

            }

            ans[y+left/2]=2;

            for(int i=(y+left/2+1);i<x-1;i++){

                ans[i]=test;

                test^=1;

            }

        }

        if(right%2==0){

            bool test=false;

            int i=x;

            i%=n;

            while(i!=y-1){

                ans[i]=test;

                test^=true;

                i++;

                i%=n;

            }

        }

        else{

            bool test=0;

            int i=x;

            i%=n;

            int test1=(x+right/2)%n;

            while(i!=test1){

                ans[i]=test;

                test^=1;

                i++;

                i%=n;

            }

            ans[i]=2;

            i++;

            i%=n;

            while(i!=y-1){

                ans[i]=test;

                test^=1;

                i++;

                i%=n;

            }

        }

        for(int i=0;i<n;i++)cout<<ans[i]<<" ";

        cout<<endl;

    }

}

#include<bits/stdc++.h>

using namespace std;

#define print_b(ans) cout<<(ans?"YES":"NO")<<endl;

#define print_n(x)        cout<<x<<endl;

#define times(x)          int x;cin>>x;while(x--)

#define debug(x) cout<<#x<<": "<<x<<endl;

typedef long long ll;

void judge(){

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

    #ifndef ONLINE_JUDGE

        freopen("input.txt","r",stdin);

        //freopen("output.txt","w",stdout);

    #endif

}

int main(){

    judge();

    times(x){

        int n,x,y;cin>>n>>x>>y;

        if(x<y)swap(x,y);

        vector<int> ans(n);

        ans[x-1]=1;

        ans[y-1]=0;

        int left=(x-y-1);

        int right=n-(x-y+1);

        if(left%2==0){

            bool test=1;

            for(int i=y;i<x-1;i++){

                ans[i]=test;

                test^=1;

            }

        }

        else{

            bool test=1;

            for(int i=y;i<(y+left/2);i++){

                ans[i]=test;

                test^=1;

            }

            ans[y+left/2]=2;

            for(int i=(y+left/2+1);i<x-1;i++){

                ans[i]=test;

                test^=1;

            }

        }

        if(right%2==0){

            bool test=false;

            int i=x;

            i%=n;

            while(i!=y-1){

                ans[i]=test;

                test^=true;

                i++;

                i%=n;

            }

        }

        else{

            bool test=0;

            int i=x;

            i%=n;

            int test1=(x+right/2)%n;

            while(i!=test1){

                ans[i]=test;

                test^=1;

                i++;

                i%=n;

            }

            ans[i]=2;

            i++;

            while(i!=y-1){

                ans[i]=test;

                test^=1;

                i++;

                i%=n;

            }

        }

        for(int i=0;i<n;i++)cout<<ans[i]<<" ";

        cout<<endl;

    }

}

Answer: 1


#pragma optimize GCC(2)

#pragma optimize GCC(3)

#pragma optimize GCC("Ofast")

#include <bits/stdc++.h>

#define endl '\n'

// #define int long long

#define lowbit(x) x & -x

using i64 = long long;

using u64 = unsigned long long;

using ld = long double;

const int maxn = 2e5 + 5;

const int inf = 0x7f7f7f7f;

const int mod = 1e9 + 7;

struct custom_hash

{

	static uint64_t splitmix64(uint64_t x)

    {

		x ^= x << 13;

		x ^= x >> 7;

		x ^= x << 17;

		return x;

	}

	size_t operator () (uint64_t x) const

    {

		static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count(); // 时间戳

		return splitmix64(x + FIXED_RANDOM);

	}

};

void solve()

{

    int n = 0, x = 0, y = 0;

    std::cin >> n >> x >> y;

    if (n & 1)

    {

        if (abs(x - y) & 1)

        {

            std::cout << 2 << " ";

            for (int i = 1; i <= n - 1; i++)

            {

                std::cout << (i % 2) << " ";

            }

            std::cout << endl;

            return;

        }

        else

        {

            for (int i = 1; i <= n; i++)

            {

                if (i == x)

                {

                    std::cout << 2 << " ";

                }

                else

                {

                    if(abs(x - i) & 1)

                    {

                        std::cout << 1 << " ";

                    }

                    else

                    {

                        std::cout << 0 << " ";

                    }

                }

            }

            std::cout << endl;

            return;

        }

    }

    else

    {

        if (abs(x - y) & 1)

        {

            for (int i = 1; i <= n; i++)

            {

                std::cout << (i + 1) % 2 << " ";

            }

            std::cout << endl;

            return;

        }

        else

        {

            for (int i = 1; i <= n; i++)

            {

                if (i == x)

                {

                    std::cout << 2 << " ";

                }

                else if (abs(x - i) & 1)

                {

                    std::cout << 1 << " ";

                }

                else

                {

                    std::cout << 0 << " ";

                }

            }

            std::cout << endl;

            return;

        }

    }

}

signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr); std::cout.tie(nullptr);

    //freopen("out.txt", "w", stdout);

    int t = 1;

    std::cin >> t;

    while(t--)

    {

        solve();

    }

    return 0;

}

#pragma optimize GCC(2)

#pragma optimize GCC(3)

#pragma optimize GCC("Ofast")

#include <bits/stdc++.h>

#define endl '\n'

// #define int long long

#define lowbit(x) x & -x

using i64 = long long;

using u64 = unsigned long long;

using ld = long double;

const int maxn = 2e5 + 5;

const int inf = 0x7f7f7f7f;

const int mod = 1e9 + 7;

struct custom_hash

{

	static uint64_t splitmix64(uint64_t x)

    {

		x ^= x << 13;

		x ^= x >> 7;

		x ^= x << 17;

		return x;

	}

	size_t operator () (uint64_t x) const

    {

		static const uint64_t FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count(); // 时间戳

		return splitmix64(x + FIXED_RANDOM);

	}

};

void solve()

{

    int n = 0, x = 0, y = 0;

    std::cin >> n >> x >> y;

    if (n & 1)

    {

        for (int i = 1; i <= n; i++)

        {

            if (i == x)

            {

                std::cout << 2 << " ";

            }

            else if (i < x)

            {

                if ((x - i) & 1) std::cout << 0 << " ";

                if ((x - i) % 2 == 0) std::cout << 1 << " ";

            }

            else

            {

                if((i - x) & 1) std::cout << 1 << " ";

                if ((i - x) % 2 == 0) std::cout << 0 << " ";

            }

        }

        std::cout << endl;

        return;

    }

    else

    {

        if((abs(x - y) & 1) || (x == n && y == 1) || (x == 1 && y == n))

        {

            for (int i = 1; i <= n; i++)

            {

                std::cout << (i + 1) % 2 << " ";

            }

            std::cout << endl;

            return;

        }

        for (int i = 1; i <= n; i++)

        {

            if (i == x)

            {

                std::cout << 2 << " ";

            }

            else if (abs(i - x) & 1)

            {

                std::cout << 0 << " ";

            }

            else

            {

                std::cout << 1 << " ";

            }

        }

        std::cout << endl;

        return;

    }

}

signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(nullptr); std::cout.tie(nullptr);

    //freopen("out.txt", "w", stdout);

    int t = 1;

    std::cin >> t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		a[st] = 1;

			a[st+1] = 0;

			st+=2;

			if(st > n)st-=n;

	}

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

#include <bits/stdc++.h>

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		if(st > n)st-=n;

		a[st] = 1;

		if(st+1 > n)st-=n;

			a[st+1] = 0;

			st+=2;

	}

	if(st > n)st-=n;

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

Answer: 2


/*-----AUTHOR--------

-------FREEBIE-------

https://codeforces.com/profile/freebie

*/

# include <bits/stdc++.h>

using namespace std;

# define ll long long

# define pb push_back

# define mp make_pair

# define f first

# define s second

# define mod 1000000007

# define py cout << "YES" << endl

# define pn cout << "NO" << endl

# define INF 1e18

# define vi vector<int>

# define vc vector<char>

# define vll vector<ll>

# define pii pair<int, int>

# define pll pair<ll, ll>

# define vvi vector<vi>

# define vvc vector<vc>

# define vpii vector<pii>

# define vpll vector<pll>

# define all(x) x.begin(), x.end()

# define endl "\n"

# define forn(i, n) for(int i = 0; i < n; i++)

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

int gcd(int a, int b){

    if(b == 0){

        return a;

    }

    return gcd(b, a%b);

}

int lcm(int a, int b){

    return (a*b)/gcd(a, b);

}

bool isPrime(int n){

    if(n == 1){

        return false;

    }

    for(int i = 2; i*i <= n; i++){

        if(n%i == 0){

            return false;

        }

    }

    return true;

}

void sieve(int n){

    bool prime[n+1];

    memset(prime, true, sizeof(prime));

    for(int p = 2; p*p <= n; p++){

        if(prime[p] == true){

            for(int i = p*p; i <= n; i += p){

                prime[i] = false;

            }

        }

    }

}

ll binpow(ll a, ll b){

    if(b == 0) return 1;

    if(b%2){

        return (a * binpow(a, b-1)) % mod;

    }

    return binpow((a*a) % mod, b/2);

}

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    // vi v(n+1);

    if(x == 1 && y == n){

        // simply alternate between 0 and 1 if n is even

        if(n%2 == 0){

            for(ll i=0 ; i<n ; i++){

                cout << i%2 << " ";

            }

        }

        else{

            // if n is odd, then we need to print 0, 1, 0, 1, 0, 1, 0, 1, 0

            for(ll i=0 ; i<n-1 ; i++){

                cout << i%2 << " ";

            }

            cout << 2;

        }

        return;

    }

    if(y == x+1){

        if(n%2 == 0){

            for(ll i=0 ; i<n ; i++){

                cout << i%2 << " ";

            }

        }

        else{

            // if n is odd, then we need to print 0, 1, 0, 1, 0, 1, 0, 1, 0

            for(ll i=0 ; i<n-1 ; i++){

                cout << i%2 << " ";

            }

            cout << 2;

        }

        return;

    }

    vi v(n);

    v[x-1] = 0;

    v[y-1] = 1;

    for(ll i=x ; i+1<y ; i++){

        v[i] = 1 - v[i-1];

    }

    // 0 1 0 1 assign krne ke baad, we need  to check if we have same numbers occuring

    if(v[y-1] == v[y-2]){

        v[y-2] = 2;

    }

    ll prev = v[y-1];

    ll cnt  = 2;

    for(ll i=y%n ; i!=x-1 ; i= (i+1)%n){

        cnt++;

    }

    if(cnt%2){

        v[y%n] = 2;

        for( ll i = (y+1)%n ; i!=x-1 ; i = (i+1)%n){

            v[i] = 1 - prev;

            prev = v[i];

        }

    }

    else{

        for(ll i = (y+1)%n ; i!=x-1 ; i = (i+1)%n){

            v[i] = 1 - prev;;

            prev = v[i];

        }

    }

    for(auto i : v){

        cout << i << " ";

    }

    return;

}

int main()

{

    fast;

    int TCS;

    cin >> TCS;

    // TCS = 1;

    for (int TC = 1; TC <= TCS; ++TC)

    {

      solve();

    }

}

/*-----AUTHOR--------

-------FREEBIE-------

https://codeforces.com/profile/freebie

*/

# include <bits/stdc++.h>

using namespace std;

# define ll long long

# define pb push_back

# define mp make_pair

# define f first

# define s second

# define mod 1000000007

# define py cout << "YES" << endl

# define pn cout << "NO" << endl

# define INF 1e18

# define vi vector<int>

# define vc vector<char>

# define vll vector<ll>

# define pii pair<int, int>

# define pll pair<ll, ll>

# define vvi vector<vi>

# define vvc vector<vc>

# define vpii vector<pii>

# define vpll vector<pll>

# define all(x) x.begin(), x.end()

# define endl "\n"

# define forn(i, n) for(int i = 0; i < n; i++)

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

int gcd(int a, int b){

    if(b == 0){

        return a;

    }

    return gcd(b, a%b);

}

int lcm(int a, int b){

    return (a*b)/gcd(a, b);

}

bool isPrime(int n){

    if(n == 1){

        return false;

    }

    for(int i = 2; i*i <= n; i++){

        if(n%i == 0){

            return false;

        }

    }

    return true;

}

void sieve(int n){

    bool prime[n+1];

    memset(prime, true, sizeof(prime));

    for(int p = 2; p*p <= n; p++){

        if(prime[p] == true){

            for(int i = p*p; i <= n; i += p){

                prime[i] = false;

            }

        }

    }

}

ll binpow(ll a, ll b){

    if(b == 0) return 1;

    if(b%2){

        return (a * binpow(a, b-1)) % mod;

    }

    return binpow((a*a) % mod, b/2);

}

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    // vi v(n+1);

    // if(x == 1 && y == n){

    //     // simply alternate between 0 and 1 if n is even

    //     if(n%2 == 0){

    //         for(ll i=0 ; i<n ; i++){

    //             cout << i%2 << " ";

    //         }

    //     }

    //     else{

    //         // if n is odd, then we need to print 0, 1, 0, 1, 0, 1, 0, 1, 0

    //         for(ll i=0 ; i<n-1 ; i++){

    //             cout << i%2 << " ";

    //         }

    //         cout << 2;

    //     }

    //     return;

    // }

    // else if(y == x+1){

    //     if(n%2 == 0){

    //         for(ll i=0 ; i<n ; i++){

    //             cout << i%2 << " ";

    //         }

    //     }

    //     else{

    //         // if n is odd, then we need to print 0, 1, 0, 1, 0, 1, 0, 1, 0

    //         for(ll i=0 ; i<n-1 ; i++){

    //             cout << i%2 << " ";

    //         }

    //         cout << 2;

    //     }

    //     return;

    // }

    // else{

    //     vi v(n);

    //     v[x-1] = 0;

    //     v[y-1] = 1;

    //     for(ll i=x ; i+1<y ; i++){

    //         v[i] = 1 - v[i-1];

    //     }

    //     // 0 1 0 1 assign krne ke baad, we need  to check if we have same numbers occuring

    //     if(v[y-1] == v[y-2]){

    //         v[y-2] = 2;

    //     }

    //     ll prev = v[y-1];

    //     ll cnt  = 2;

    //     for(ll i=y%n ; i!=x-1 ; i= (i+1)%n){

    //         cnt++;

    //     }

    //     if(cnt%2){

    //         v[y%n] = 2;

    //         for( ll i = (y+1)%n ; i!=x-1 ; i = (i+1)%n){

    //             v[i] = 1 - prev;

    //             prev = v[i];

    //         }

    //     }

    //     else{

    //         for(ll i = y%n ; i!=x-1 ; i = (i+1)%n){

    //             v[i] = 1 - prev;;

    //             prev = v[i];

    //         }

    //     }

    //     for(ll i=0 ; i<n ; i++){

    //         cout << v[i] << " ";

    //     }

    // }

    --x;--y;

    vi ans(n);

    for(int i=0 ; i<n ; i++){

        ans[(x+i)%n] = i%2;

    }

    if(n % 2 || (x-y) % 2 == 0){

        ans[x] = 2;

    }

    for(int i=0 ; i<n ; i++){

        cout << ans[i] << " ";

    }

    cout << endl;

}

int main()

{

    fast;

    int TCS;

    cin >> TCS;

    // TCS = 1;

    for (int TC = 1; TC <= TCS; ++TC)

    {

      solve();

    }

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

#define ff first

#define ss second

#define pii pair<int,int>

#define vi vector<int>

#define vii vector<pair<int,int>>

void solve()

{

    int n,x,y;

    cin >> n>>x>>y;

    vi v(n);

    x--,y--;

    for(int i=0; i<n; i++){

        v[(x + i) % n] = i % 2;

    }

    if (n % 2 || (x - y) % 2 == 0)

        v[x] = 2;

    for(int i=0; i<v.size(); i++){

        cout<<v[i]<<" ";

    }

    cout<<endl;

}

signed main()

{

    int tcs;

    cin >> tcs;

    while (tcs--)

    {

        solve();

    }

}

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

#define ff first

#define ss second

#define pii pair<int,int>

#define vi vector<int>

#define vii vector<pair<int,int>>

void solve()

{

    int n,x,y;

    cin >> n>>x>>y;

    vi v(n);

    if(x&1 && y&1){

        v[x-1]=0;

        v[y-1]=2;

    }else{

        v[x-1]=1;

        v[y-1]=2;

    }

    int i=x-2;

    while(i>=0){

        if(v[i+1]==0){

            v[i]=1;

        }else{

            v[i]=0;

        }

        i--;

    }

    i=x;

    while(i<y-1){

        if(v[i-1]==0){

            v[i]=1;

        }else{

            v[i]=0;

        }

        i++;

    }

    i=y;

    while(i<n){

        if(v[i-1]==0){

            v[i]=1;

        }else{

            v[i]=0;

        }

        i++;

    }

    for(i=0; i<v.size(); i++){

        cout<<v[i]<<" ";

    }

    cout<<endl;

}

signed main()

{

    int tcs;

    cin >> tcs;

    while (tcs--)

    {

        solve();

    }

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }

template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef LOCAL

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#else

#define dbg(...)

#endif

#define ar array

#define ll long long

#define ld long double

#define sza(x) ((int)x.size())

#define all(a) (a).begin(), (a).end()

const int MAX_N = 1e5 + 5;

const ll MOD = 1e9 + 7;

const ll INF = 1e9;

const ld EPS = 1e-9;

void solve() {

	ll n,x,y;

	cin>>n>>x>>y;

	if(n%2==0){

			for(int i=1;i<=n;i++){

				if(i==x && (y-x)%2==0)cout<<2<<" ";

				else if(i%2==0)cout<<1<<" ";

				else cout<<0<<" ";

			}

			cout<<'\n';

	}

	else{

			for(int i=1;i<=x-1;i++){

				if(i%2==0)cout<<0<<" ";

				else cout<<1<<" ";

			}

			cout<<2<<" ";

			if(x%2==0){

				for(int i=x+1;i<=n;i++){

					if(i%2==0)cout<<1<<" ";

					else cout<<0<<" ";

				}

			}

			else{

				for(int i=x+1;i<=n;i++){

					if(i%2==0)cout<<0<<" ";

					else cout<<1<<" ";

				}

			}

			cout<<'\n';

	}

}

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    int tc = 1;

     cin >> tc;

    for (int t = 1; t <= tc; t++) {

        // cout << "Case #" << t << ": ";

        solve();

    }

}

#include <bits/stdc++.h>

using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }

template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef LOCAL

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#else

#define dbg(...)

#endif

#define ar array

#define ll long long

#define ld long double

#define sza(x) ((int)x.size())

#define all(a) (a).begin(), (a).end()

const int MAX_N = 1e5 + 5;

const ll MOD = 1e9 + 7;

const ll INF = 1e9;

const ld EPS = 1e-9;

void solve() {

	ll n,x,y;

	cin>>n>>x>>y;

	if(n%2==0){

			for(int i=1;i<=n;i++){

				if(i==x && (y-x)%2==0)cout<<2<<" ";

				else if(i%2==0)cout<<1<<" ";

				else cout<<0<<" ";

			}

			cout<<'\n';

	}

	else{

			for(int i=1;i<=x-1;i++){

				if(i%2==0)cout<<0<<" ";

				else cout<<1<<" ";

			}

			cout<<2<<" ";

				for(int i=x+1;i<=n;i++){

					if(i%2==0)cout<<1<<" ";

					else cout<<0<<" ";

				}

			cout<<'\n';

	}

}

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    int tc = 1;

     cin >> tc;

    for (int t = 1; t <= tc; t++) {

        // cout << "Case #" << t << ": ";

        solve();

    }

}

Answer: 2


#include<bits/stdc++.h>

#define ll long long

#define hachimi cat

#define oukinkin milktea

#define bacon maozedong

#define my_son dengxiaoping

#define winnie xijinping

#define N 200005

using namespace std;

int n,x,y;

int a[N];

int main(){

	std::ios::sync_with_stdio(0);

	cin.tie(0),cout.tie(0);

	int T;cin>>T;

	while(T--){

		cin>>n>>x>>y;

		for(int i=1;i<=n;i++){

			a[(x+i-1)%n+1]=i%2;

		}

		if(n%2||abs(x-y)%2==0){

			a[x]=2;

		}

		for(int i=1;i<=n;i++){

			cout<<a[i]<<' ';

		}cout<<endl;

	}

	return 0;

}

#include<bits/stdc++.h>

#define ll long long

#define hachimi cat

#define oukinkin milktea

#define bacon maozedong

#define my_son dengxiaoping

#define winnie xijinping

#define N 200005

using namespace std;

int n;

ll a[305][305],b[305];

int main(){

	std::ios::sync_with_stdio(0);

	cin.tie(0),cout.tie(0);

	int T;cin>>T;

	while(T--){

		cin>>n;

		for(int i=1;i<=n;i++){

			a[i][n+1]=1;b[i]=0;

			for(int j=1;j<=n;j++){

				cin>>a[i][j];

			}

		}

		for(int i=1;i<=n;i++){

			for(int j=n-1;j>=1;j--){

				a[i][j]+=a[i][j+1];

			}

		}

		priority_queue<int,vector<int>,greater<int> > q;

		for(int i=1;i<=n;i++){

			for(int j=1;j<=n;j++){

				if(a[i][j]==n-j+1){

					q.push(n-j+1);break;

				}

			}

		}

		//cout<<"ans=";

		int ans=0;

		while(!q.empty()){

			int x=q.top();q.pop();

			if(x>=ans){

				ans++;

			}

			cout<<x<<' ';

		}

		ans++;

		cout<<ans<<endl;

	}

	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;

typedef long long ll;

template <class type1>

using ordered_multiset = tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;

typedef __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define pb push_back

#define pp pop_back

#define endl '\n'

#define dbg(x) cerr << #x << " = " << x << endl

const int mod = 1e9 + 7;

const double e = 1e-6;

void solve() {

    ll n, x, y;

    cin >> n >> x >> y;

    vector<ll> a(n+1);

    if(y < x) swap(x, y);

    if((y-x)%2 || (n+y-x)%2) {

        for(ll i = 0; x+i < y; ++i){

            if(i%2) a[i+x] = 1;

            else a[i+x] = 0;

        }

        a[y] = 2;

        for(ll i = 0; (n+x-i) > y  ; i++){

            if((x-i)%2){

                if((n+x-i)%n == 0) a[n] = 1;

                else a[(n+x-i)%n] = 1;

            }

            else{

                if((n+x-i)%n == 0) a[n] = 0;

                else a[(n+x-i)%n] = 0;

            }

        }

    }

    else{

        for(ll i = 0; i < n; ++i){

            if(i%2){

                if((x+i)%n == 0) a[n] = 1;

                else a[(x+i)%n] = 1;

            }

            else{

                if((x+i)%n == 0) a[n] = 0;

                else a[(x+i)%n] = 0;

            }

        }

    }

    for(ll i = 1; i <= n; ++i) cout << a[i] << " ";

    cout << endl;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t; while(t--)

    solve();

}

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

typedef long long ll;

template <class type1>

using ordered_multiset = tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;

typedef __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

#define pb push_back

#define pp pop_back

#define endl '\n'

#define dbg(x) cerr << #x << " = " << x << endl

const int mod = 1e9 + 7;

const double e = 1e-6;

void solve() {

    ll n, x, y;

    cin >> n >> x >> y;

    vector<ll> a(n+1);

    if(y < x) swap(x, y);

    if((y-x)%2 == 0 || (n+y-x)%2 == 0){

        for(ll i = 0; x+i < y; ++i){

            if(i%2) a[i+x] = 1;

            else a[i+x] = 0;

        }

        a[y] = 2;

        for(ll i = 0; (n+x-i) > y  ; i++){

            if(i%2){

                if((n+x-i)%n == 0) a[n] = 1;

                else a[(n+x-i)%n] = 1;

            }

            else{

                if((n+x-i)%n == 0) a[n] = 0;

                else a[(n+x-i)%n] = 0;

            }

        }

    }

    else{

        for(ll i = 0; i < n; ++i){

            if(i%2){

                if((x+i)%n == 0) a[n] = 1;

                else a[(x+i)%n] = 1;

            }

            else{

                if((x+i)%n == 0) a[n] = 0;

                else a[(x+i)%n] = 0;

            }

        }

    }

    for(ll i = 1; i <= n; ++i) cout << a[i] << " ";

    cout << endl;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t; cin >> t; while(t--)

    solve();

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

int cha(int a,int b){

	if (a>b) swap(a,b);

	return min(b-a,a+n-b);

}

void solve(){

	cin>>n>>x>>y;

	if (x>y) swap(x,y);

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

		if (n%2==1){

			for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

			cout<<2<<" ";

		}

		else for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

		for (int i=1,t=0;i<=n;i++){

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

		if (a%2==0){

			for (int i=1,t=0;i<=n;i++){

				t^=1;

				if (i==x){

					cout<<2<<" ";

					continue;

				}

				cout<<t<<" ";

			}

		}

		else for (int i=1;i<=n;i++) cout<<i%2<<" ";

		cout<<'\n';

		return;

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

const int N=505;

int t,n,x,y;

void solve(){

	cin>>n>>x>>y;

	if (x>y) swap(x,y);

	int a=y-x,b=x+n-y;

	if (a>b) swap(a,b);

	if (a==1){

		if (n%2==1){

			for (int i=1;i<=n-1;i++) cout<<i%2<<" ";

			cout<<2<<" ";

		}

		else for (int i=1;i<=n;i++) cout<<i%2<<" ";

		cout<<'\n';

		return;

	}

	if (a%2!=b%2){

		for (int i=1,t=0;i<=n;i++){

			if (i==x){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

		cout<<'\n';

		return;

	}

	if (a%2==b%2){

		if (a%2==0){

			for (int i=1;i<=n;i++){

				if (i==x){

					cout<<2<<" ";

					continue;

				}

				cout<<i%2<<" ";

			}

		}

		else for (int i=1;i<=n;i++) cout<<i%2<<" ";

		cout<<'\n';

		return;

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

Answer: 2


#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;

template <class type1>

#define ll long long int

#define endl "\n"

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;

#define vsort sort(v.begin(),v.end())

#define yes cout << "Yes\n"

#define no cout << "No\n"

ll lcm(ll x, ll y)

{

    return (x * y) / __gcd(x, y);

}

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

   while(t--)

    {

        ll n;

        cin>>n;

        ll odd=0,even=0,sum=0;

        ll oo,ee;

        vector<ll>v;

        for(int i=0;i<n;i++)

        {

            ll x;

            cin>>x;

            if((i+1)%2!=0)odd+=x;

            else even+=x;

            sum+=x;

            v.push_back(x);

        }

        oo=(n+1)/2;

        ee=n/2;

        ll k=sum/n;

        //cout<<even<<" "<<odd<<" "<<k*ee<<" "<<k*oo<<endl;

        if(sum%n!=0)no;

        else if((odd==k*oo) && (even==ee*k))yes;

        else no;

    }

    return 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;

template <class type1>

#define ll long long int

#define endl "\n"

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;

#define vsort sort(v.begin(),v.end())

#define yes cout << "Yes\n"

#define no cout << "No\n"

ll lcm(ll x, ll y)

{

    return (x * y) / __gcd(x, y);

}

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

   while(t--)

    {

        int n;

        cin>>n;

        int odd=0,even=0,sum=0;

        int oo,ee;

        vector<int>v;

        for(int i=0;i<n;i++)

        {

            int x;

            cin>>x;

            if((i+1)%2!=0)odd+=x;

            else even+=x;

            sum+=x;

            v.push_back(x);

        }

        oo=(n+1)/2;

        ee=n/2;

        int k=sum/n;

        //cout<<even<<" "<<odd<<" "<<k*ee<<" "<<k*oo<<endl;

        if(sum%n!=0)no;

        else if((odd==k*oo) && (even==ee*k))yes;

        else no;

    }

    return 0;

}

Answer: 1