#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

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

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

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

		else{

			if(x == 2)swap(a[x], a[1]);

			else if(y == n)swap(a[y], a[1]);

			else a[x] = 2;

		}

	}

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

		cout << '\n';

}

int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*

*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll inf = 4e18;

const int N = 2e5 + 5;

int n, x, y;

int a[N];

void solve(){

	cin >> n >> x >> y;

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

		a[i] = (i - 1) % 2;

	}

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

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

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

		else{

			if(x == 2)swap(a[x], a[1]);

			else if(y == n)swap(a[y], a[1]);

			else a[y] = 2;

		}

	}

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

		cout << '\n';

}

int main(){

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

	int _ = 1;cin >> _;

	while(_ --){

		solve();

	}

	return 0;

}

/*

*/

Answer: 2


#include <iostream>

#include <algorithm>

#include <string>

#include <cstring>

#include <cmath>

#include <iomanip>

#include <queue>

#include <vector>

#include <stack>

#include <functional>

#include <array>

#include <set>

#include <map>

#include <unordered_map>

#include <unordered_set>

using namespace std;

#define ll long long

#define mod 998244353

const int N = 1e6 + 5;

ll oo = 0x3f3f3f3f3f3f3f3f;

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

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

char ch[] = {'R', 'L', 'U', 'D'};

int main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  if (fopen("input.txt", "r"))

  {

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

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

  }

  int t = 1;

  cin >> t;

  while (t--)

  {

    int n, m, k;

    cin >> n >> m >> k;

    vector<int> v(n + 1);

    v[k] = 1e9;

    if (m == 1)

      v[n] = 1;

    else

      v[m - 1] = 1;

    if (m == n)

      v[1] = 1;

    else

      v[m + 1] = 1;

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

    {

      if (i == m)

        continue;

      if (i == k)

      {

        int j = 0;

        vector<int> a;

        if (i == 1)

        {

          a.push_back(v[n]);

        }

        else

          a.push_back(v[i - 1]);

        if (i == n)

          a.push_back(v[1]);

        else

          a.push_back(v[i + 1]);

        if ((i + 1) % n != m % n && (i - 1 != m || (i == 1 && m != n)))

          a.push_back(v[m]);

        sort(a.begin(), a.end());

        for (auto it : a)

        {

          if (it == j)

            j++;

        }

        v[i] = j;

      }

      else

      {

        int j = 0;

        vector<int> a;

        if (i == 1)

        {

          a.push_back(v[n]);

        }

        else

          a.push_back(v[i - 1]);

        if (i == n)

          a.push_back(v[1]);

        else

          a.push_back(v[i + 1]);

        sort(a.begin(), a.end());

        for (auto it : a)

        {

          if (it == j)

            j++;

        }

        v[i] = j;

      }

    }

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

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

    cout << '\n';

  }

  return 0;

}

#include <iostream>

#include <algorithm>

#include <string>

#include <cstring>

#include <cmath>

#include <iomanip>

#include <queue>

#include <vector>

#include <stack>

#include <functional>

#include <array>

#include <set>

#include <map>

#include <unordered_map>

#include <unordered_set>

using namespace std;

#define ll long long

#define mod 998244353

const int N = 1e6 + 5;

ll oo = 0x3f3f3f3f3f3f3f3f;

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

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

char ch[] = {'R', 'L', 'U', 'D'};

int main()

{

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  cout.tie(nullptr);

  if (fopen("input.txt", "r"))

  {

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

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

  }

  int t = 1;

  cin >> t;

  while (t--)

  {

    int n, m, k;

    cin >> n >> m >> k;

    vector<int> v(n + 1);

    v[k] = 1e9;

    if (m == 1)

      v[n] = 1;

    else

      v[m - 1] = 1;

    if (m == n)

      v[1] = 1;

    else

      v[m + 1] = 1;

    int q = 10;

    while (q--)

    {

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

      {

        if (i == m)

          continue;

        if (i == k)

        {

          int j = 0;

          vector<int> a;

          if (i == 1)

          {

            a.push_back(v[n]);

          }

          else

            a.push_back(v[i - 1]);

          if (i == n)

            a.push_back(v[1]);

          else

            a.push_back(v[i + 1]);

          if ((i + 1) % n != m % n && (i - 1 != m || (i == 1 && m != n)))

            a.push_back(v[m]);

          sort(a.begin(), a.end());

          for (auto it : a)

          {

            if (it == j)

              j++;

          }

          v[i] = j;

        }

        else

        {

          int j = 0;

          vector<int> a;

          if (i == 1)

          {

            a.push_back(v[n]);

          }

          else

            a.push_back(v[i - 1]);

          if (i == n)

            a.push_back(v[1]);

          else

            a.push_back(v[i + 1]);

          sort(a.begin(), a.end());

          for (auto it : a)

          {

            if (it == j)

              j++;

          }

          v[i] = j;

        }

      }

    }

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

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

    cout << '\n';

  }

  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;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

#define int long long

#define pb push_back

#define endl '\n'

#define vi vector<int>

const int Mod=1e9+7;

const int N=1e6;

#define ld long double

#define vpi vector<pair<int,int>>

const int MOD = 1e9 + 7;

#define mii map<int, int>

#define vvi vector<vi>

#define rep(i,x,y) for(int i=x; i<y; i++)

 bool primenumber(int n){

     vector<bool> prime(n+1,1);

     prime[0]=0;

     prime[1]=0;

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

         if(prime[i]){

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

                 prime[j]=0;

                 }}}

     return prime[n];

 }

 int power(int x,int n){

     // calculating the power by binary exponentiation

     int ans=1;

     if(n==0){

         return 1;

     }

     if(n%2 == 0){

         // even power case

    ans=power(x*x,n/2);

     }

     else {

         //odd power case

       ans=x*power(x*x,n/2);

     }

     return ans;

 }

int ncr(int n,int r){

    if(r==0 || r==n) return 1;

    if(r==1) return n;

    int res=1;

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

        res*=(n-i+1);

        res/=(i);

    }

    return res;

}

// factorial

unsigned int factorial(unsigned int n)

{

    if (n == 0 || n == 1)

        return 1;

    return n * factorial(n - 1);

}

// sort the vactor pair based on second element

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

     return a.second < b.second;

 }

// Function to calculate (base^exponent) % mod

int  modExp(int base, int  exponent, int mod) {

    int result = 1;

    while (exponent > 0) {

        if (exponent % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exponent /= 2;

    }

    return result;

}

// Function to calculate (P * Q^-1) % MOD

int calculateModInverse(int P, int Q) {

    int Q_inv = modExp(Q, MOD - 2, MOD);

    return (P * Q_inv) % MOD;

}

int gcd(int a, int b) {

    while (b != 0) {

        int temp = b;

        b = a % b;

        a = temp;

    }

    return a;

}

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

int32_t main(){

    FASTIO();

    cout<<setprecision(21)<<fixed;

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        vi ans(n,-1);

       x--;

       y--;

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

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

       }

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

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

       cout<<endl;

    }

    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;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

#define int long long

#define pb push_back

#define endl '\n'

#define vi vector<int>

const int Mod=1e9+7;

const int N=1e6;

#define ld long double

#define vpi vector<pair<int,int>>

const int MOD = 1e9 + 7;

#define mii map<int, int>

#define vvi vector<vi>

#define rep(i,x,y) for(int i=x; i<y; i++)

 bool primenumber(int n){

     vector<bool> prime(n+1,1);

     prime[0]=0;

     prime[1]=0;

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

         if(prime[i]){

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

                 prime[j]=0;

                 }}}

     return prime[n];

 }

 int power(int x,int n){

     // calculating the power by binary exponentiation

     int ans=1;

     if(n==0){

         return 1;

     }

     if(n%2 == 0){

         // even power case

    ans=power(x*x,n/2);

     }

     else {

         //odd power case

       ans=x*power(x*x,n/2);

     }

     return ans;

 }

int ncr(int n,int r){

    if(r==0 || r==n) return 1;

    if(r==1) return n;

    int res=1;

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

        res*=(n-i+1);

        res/=(i);

    }

    return res;

}

// factorial

unsigned int factorial(unsigned int n)

{

    if (n == 0 || n == 1)

        return 1;

    return n * factorial(n - 1);

}

// sort the vactor pair based on second element

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

     return a.second < b.second;

 }

// Function to calculate (base^exponent) % mod

int  modExp(int base, int  exponent, int mod) {

    int result = 1;

    while (exponent > 0) {

        if (exponent % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exponent /= 2;

    }

    return result;

}

// Function to calculate (P * Q^-1) % MOD

int calculateModInverse(int P, int Q) {

    int Q_inv = modExp(Q, MOD - 2, MOD);

    return (P * Q_inv) % MOD;

}

int gcd(int a, int b) {

    while (b != 0) {

        int temp = b;

        b = a % b;

        a = temp;

    }

    return a;

}

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

int32_t main(){

    FASTIO();

    cout<<setprecision(21)<<fixed;

    int t;

    cin>>t;

    while(t--){

        int n,x,y;

        cin>>n>>x>>y;

        vi ans(n,-1);

        ans[x-1]=0;

        ans[y-1]=1;

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

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

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

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

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

    if(ans[i]==-1)ans[i]=1;

   }

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

   cout<<endl;

    }

    return 0;

}

Answer: 1


def solve():

    n, x, y = map(int, input().split())

    x-=1

    y-=1

    a = [0]*n

    #x, x+1, ..., y

    if (y-x+1)%2 == 0:

        #偶数だべ

        #x, yは0, 1にする

        for i in range(x, y+1):

            a[i] = (i-x)%2

    else:

        #奇数なり

        #x, yは0, 1にする

        for i in range(x, y+1):

            a[i] = (i-x)%2

        #0, 2, 1

        a[y-1] = 2

        a[y] = 1

    #y, y+1, ..., n-1, 0, ..., x

    x += n

    if (x-y+1)%2 == 0:

        #偶数だ～～～！！！！！

        #x, yは0, 1にする

        for i in range(y, x+1):

            if (i-y)%2 == 0:

                a[i%n] = 1

            else:

                a[i%n] = 0

    else:

        #奇数だよ

        #x, yは0, 1にする

        for i in range(y, x+1):

            a[i%n] = (x-i)%2

        a[y] = 1

        a[(y+1)%n] = 2

    print(*a, sep = " ")

for _ in range(int(input())):

    solve()

def solve():

    n, x, y = map(int, input().split())

    x-=1

    y-=1

    a = [0]*n

    #x, x+1, ..., y

    if (y-x+1)%2 == 0:

        #偶数だべ

        #x, yは0, 1にする

        for i in range(x, y+1):

            a[i] = (i-x)%2

    else:

        #奇数なり

        #x, yは0, 1にする

        for i in range(x, y+1):

            a[i] = (i-x)%2

        #0, 2, 1

        a[y-1] = 2

        a[y] = 1

    #y, y+1, ..., n-1, 0, ..., x

    x += n

    if (x-y+1)%2 == 0:

        #偶数だ～～～！！！！！

        #x, yは0, 1にする

        for i in range(y, x+1):

            if (i-y)%2 == 0:

                a[i%n] = 0

            else:

                a[i%n] = 1

    else:

        #奇数だよ

        #x, yは0, 1にする

        for i in range(y, x+1):

            a[i%n] = (x-i)%2

        a[y] = 1

        a[(y+1)%n] = 2

    print(*a, sep = " ")

for _ in range(int(input())):

    solve()

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define lli long long int

void solve(){

	lli n, x, y;

	cin >> n >> x >> y;

	vector <lli> a1(n), a2(n);

	lli st = 1;

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

		a1[i] = st;

		st = 1-st;

	}

	st = 0;

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

		a2[i] = st;

		st = 1 -st;

	}

	if(n&1){

		a1[n-1] = 2;

		a2[n-1] = 2;

	}

	bool yes1 = false, yes2 = false;

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

		yes1 = true;

		goto label;

	}

	x--; y--;

	if(a1[x] == 1){

		a1[x] = 2;

		yes1 = true;

	}

	else if((a1[y] == 1)){

		a1[y] = 2;

		yes1 = true;

	}

	else if(a2[x] == 1){

		a2[x] = 2;

		yes2 = true;

	}

	else if(a2[y] == 1){

		a2[y] = 2;

		yes2 = true;

	}

	label:

	if(yes1){

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

			cout << a1[i] << " ";

		}

		cout << endl;

	}

	else{

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

			cout << a2[i] << " ";

		}

		cout << endl;

	}

}

#define lli long long int

int main(){

    ios_base::sync_with_stdio(false);

#ifndef ONLINE_JUDGE

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

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

#endif

	lli t;

	cin >> t;

	// t = 1;

	while(t--){

		solve();

	}

#ifndef ONLINE_JUDGE

    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

#endif

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define lli long long int

void solve(){

	lli n, x, y;

	cin >> n >> x >> y;

	vector <lli> a1(n), a2(n);

	lli st = 1;

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

		a1[i] = st;

		st = 1-st;

	}

	st = 0;

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

		a2[i] = st;

		st = 1 -st;

	}

	if(n&1){

		a1[n-1] = 2;

		a2[n-1] = 2;

	}

	bool yes1 = false, yes2 = false;

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

		yes1 = true;

		goto label;

	}

	x--; y--;

	if(a1[x] == 1 && !((n&1) && (x == 0))){

		a1[x] = 2;

		yes1 = true;

	}

	else if((a1[y] == 1) && !((n&1) && (y == (n-2)))){

		a1[y] = 2;

		yes1 = true;

	}

	else if(a2[x] == 1 && !((n&1) && (x == 0))){

		a2[x] = 2;

		yes2 = true;

	}

	else if((a2[y] == 1) && !((n&1) && (y == (n-2)))){

		a2[y] = 2;

		yes2 = true;

	}

	label:

	if(yes1){

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

			cout << a1[i] << " ";

		}

		cout << endl;

	}

	else{

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

			cout << a2[i] << " ";

		}

		cout << endl;

	}

}

#define lli long long int

int main(){

    ios_base::sync_with_stdio(false);

#ifndef ONLINE_JUDGE

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

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

#endif

	lli t;

	cin >> t;

	// t = 1;

	while(t--){

		solve();

	}

#ifndef ONLINE_JUDGE

    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

#endif

	return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

#define int long long

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    if (n == 3){

        cout << 0 << " " << 1 << " " << 2;

        return;

    }

    if (n == 4){

        if (abs(x - y) == 2){

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

                if (i == x) cout << 0;

                else if (i == y) cout << 2;

                else cout << 1;

                cout << " ";

            }

        }

        else {

            cout << 0 << " " << 1 << " " << 0 << " " << 1;

        }

        return;

    }

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

    queue<int> q;

    q.push(x);

    while (!q.empty()){

        int cur = q.front();

        q.pop();

        int prv = (cur == 1 ? n : cur-1);

        int nxt = (cur == n ? 1 : cur+1);

        int third = -1;

        if (cur == x) third = y;

        if (cur == y) third = x;

        int ans = 0;

        if (third == -1){

            while (ans == a[prv] || ans == a[nxt]){

                ans++;

            }

        }

        else {

            while (ans == a[prv] || ans == a[nxt] || ans == a[third]){

                ans++;

            }

        }

        a[cur] = ans;

        if (a[prv] == -1) q.push(prv);

        if (a[nxt] == -1) q.push(nxt);

        if (third != -1 && a[third] == -1) q.push(third);

    }

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

}

signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t = 1;

    cin >> t;

    while (t--){

        solve();

        cout << '\n';

    }

}

#include <bits/stdc++.h>

using namespace std;

#define int long long

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    if (n == 3){

        cout << 0 << " " << 1 << " " << 2;

        return;

    }

    if (n == 4){

        if (abs(x - y) == 2){

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

                if (i == x) cout << 0;

                else if (i == y) cout << 2;

                else cout << 1;

                cout << " ";

            }

        }

        else {

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

                if (i == x || i == y) cout << 0;

                else cout << 1;

                cout << " ";

            }

        }

        return;

    }

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

    queue<int> q;

    q.push(x);

    while (!q.empty()){

        int cur = q.front();

        q.pop();

        int prv = (cur == 1 ? n : cur-1);

        int nxt = (cur == n ? 1 : cur+1);

        int third = -1;

        if (cur == x) third = y;

        if (cur == y) third = x;

        int ans = 0;

        if (third == -1){

            while (ans == a[prv] || ans == a[nxt]){

                ans++;

            }

        }

        else {

            while (ans == a[prv] || ans == a[nxt] || ans == a[third]){

                ans++;

            }

        }

        a[cur] = ans;

        if (a[prv] == -1) q.push(prv);

        if (a[nxt] == -1) q.push(nxt);

        if (third != -1 && a[third] == -1) q.push(third);

    }

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

}

signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t = 1;

    cin >> t;

    while (t--){

        solve();

        cout << '\n';

    }

}

Answer: 1


#include<set>

#include<map>

#include<ctime>

#include<queue>

#include<stack>

#include<cmath>

#include<vector>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

const int N = 1e6 + 100;

const int MOD = 998244353;

const int INF = 1e18 + 7;

int gi()

{

   int s=0,f=1;char ch=getchar();

   while(!(ch>='0'&&ch<='9')) f=(ch=='-'?-1:1),ch=getchar();

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*f;

}

int PRINT[333];

void print(int x)

{

    if(!x)

    {

        putchar('0');

        return;

    }

    if(x<0) putchar('-'),x=-x;

    int ppp=0;

    while(x) PRINT[++ppp]=x%10,x/=10;

    for(int i=ppp;i>=1;--i) putchar(PRINT[i]+'0');

}

int T;

int n,m;

int A[N],B[N];

char ch[N];

signed main()

{

    T=gi();

    while(T--)

    {

        n=gi();

        int x=gi(),y=gi();

        if(n&1)

        {

            for(int i=1;i<n;++i) A[i]=i&1;

            A[n]=2;

        }

        else

        {

            for(int i=1;i<=n;++i) A[i]=i&1;

        }

        if(A[x]!=A[y])

        {

            for(int i=1;i<=n;++i) printf("%d ",A[i]);

            putchar('\n');

            continue;

        }

        if(A[x]==0)

        {

            if((n&1)&&(x==1||x==n-1)) A[x]=3;

            else A[x]=2;

        }

        else

        {

            if((n&1)&&(x==1||x==n-1)) A[x]=3;

            else A[x]=2;

        }

        for(int i=1;i<=n;++i) printf("%d ",A[i]);

        putchar('\n');

    }

}

#include<set>

#include<map>

#include<ctime>

#include<queue>

#include<stack>

#include<cmath>

#include<vector>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

const int N = 1e6 + 100;

const int MOD = 998244353;

const int INF = 1e18 + 7;

int gi()

{

   int s=0,f=1;char ch=getchar();

   while(!(ch>='0'&&ch<='9')) f=(ch=='-'?-1:1),ch=getchar();

   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

   return s*f;

}

int PRINT[333];

void print(int x)

{

    if(!x)

    {

        putchar('0');

        return;

    }

    if(x<0) putchar('-'),x=-x;

    int ppp=0;

    while(x) PRINT[++ppp]=x%10,x/=10;

    for(int i=ppp;i>=1;--i) putchar(PRINT[i]+'0');

}

int T;

int n,m;

int A[N],B[N];

char ch[N];

signed main()

{

    T=gi();

    while(T--)

    {

        n=gi();

        int x=gi(),y=gi();

        if(n&1)

        {

            for(int i=1;i<n;++i) A[i]=i&1;

            A[n]=2;

        }

        else

        {

            for(int i=1;i<=n;++i) A[i]=i&1;

        }

        if(A[x]!=A[y])

        {

            for(int i=1;i<=n;++i) printf("%d ",A[i]);

            putchar('\n');

            continue;

        }

        if(n%2==0)

        {

            A[x]=2;

        }

        else

        {

            int t=0;

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

            {

                if(i==x)

                {

                    A[i]=2;

                }

                else A[i]=t&1,++t;

            }

        }

        for(int i=1;i<=n;++i) printf("%d ",A[i]);

        putchar('\n');

    }

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

int arr[200005];

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}

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

    cout << "\n";

}

int main(){

	int t;

	cin>>t;

	while(t--)solve();

}

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]);

			}

		else{

			a[y-1]=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){

		int a1=a[y%n];

		int b1=a[y-2];

		int c1=a[x-1];

		a[y-1]=findMex(a1,b1,c1);

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}

Answer: 1


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

}

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){

		a[y-1]=2;

		}

	for(auto t:a){

		cout<<t<<" ";

		}

	cout<<endl;

	}

int main(){

	int t;

	cin>>t;

	while(t--){

		solve();

		}

	}

Answer: 1


// https://codeforces.com/contest/2049/problem/C

#[allow(unused_imports)]

use alg::io::read;

fn main() {

    for _ in 0..read() {

        solve();

    }

}

fn solve() {

    input! {

        n: usize,

        x: usize,

        y: usize,

    }

    let a = ring(n, x, y);

    for i in 0..n {

        print!("{} ", a[i]);

    }

    println!();

}

fn ring(n: usize, x: usize, y: usize) -> Vec<usize> {

    let x = x - 1;

    let y = y - 1;

    assert!(x < y);

    let mut a = vec![3; n];

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

        a[0] = n % 2 + 1;

        for i in 1..n {

            a[i] = (a[i - 1] + 1) % 2;

        }

        return a;

    }

    let l1 = y - x + 1;

    let l2 = x + n - y + 1;

    if n == 4 {

        a[(x + n - 1) % n] = 1;

        a[x] = 2;

        a[x + 1] = 1;

        a[y] = 0;

    } else {

        a[(x + n - 1) % n] = l2 % 2 + 1;

        a[x] = 0;

        a[x + 1] = l1 % 2 + 1;

        a[y] = 0;

    }

    for i in (x + 2)..y {

        a[i] = (a[i - 1] + 1) % 2;

    }

    for i in (y + 1)..(n + x - 1) {

        a[i % n] = (a[(i - 1) % n] + 1) % 2;

    }

    a

}

#[cfg(test)]

mod tests {

    use super::*;

    fn mex(a: &[usize]) -> usize {

        for i in 0.. {

            if !a.iter().any(|&e| e == i) {

                return i;

            }

        }

        unreachable!()

    }

    fn check(n: usize, x: usize, y: usize) {

        let a = ring(n, x, y);

        let x = x - 1;

        let y = y - 1;

        for i in 0..n {

            let mut tmp = vec![a[(i + 1) % n], a[(i + n - 1) % n]];

            if i == x {

                tmp.push(a[y]);

            } else if i == y {

                tmp.push(a[x]);

            }

            assert_eq!(a[i], mex(&tmp), "{i} {a:?}");

        }

    }

    #[test]

    fn test1() {

        check(4, 2, 4);

        check(4, 1, 4);

    }

    #[test]

    fn test2() {

        for n in 3..10 {

            for x in 1..n {

                for y in x + 1..=n {

                    check(n, x, y);

                }

            }

        }

    }

}

mod alg {

pub mod io {

#[macro_export]

macro_rules! input {

    (mut $var:ident: $kind:tt, $($rest:tt)*) => {

        let mut $var = $crate::_input_kind!($kind);

        input!($($rest)*)

    };

    ($var:ident: $kind:tt, $($rest:tt)*) => {

        let $var = $crate::_input_kind!($kind);

        input!($($rest)*)

    };

    (mut $var:ident: $kind:tt) => { let mut $var = $crate::_input_kind!($kind); };

    ($var:ident: $kind:tt) => { let $var = $crate::_input_kind!($kind); };

    () => {};

}

#[doc(hidden)]

#[macro_export]

macro_rules! _input_kind {

    ([$t:tt; $n:expr]) => {

        (0..$n).map(|_| $crate::_input_kind!($t)).collect::<Vec<_>>()

    };

    ([$t:tt]) => {{

        let n = $crate::_input_kind!(usize);

        (0..n).map(|_| $crate::_input_kind!($t)).collect::<Vec<_>>()

    }};

    (($a:tt, $b:tt)) => {{

        let a = $crate::_input_kind!($a);

        let b = $crate::_input_kind!($b);

        (a, b)

    }};

    (bytes) => {

        $crate::_input_kind!(String).into_bytes()

    };

    (usize1) => {

        $crate::_input_kind!(usize) - 1

    };

    ($t:ty) => {

        $crate::alg::io::read::<$t>()

    };

}

pub fn read<T>() -> T

where

    T: std::str::FromStr,

    T::Err: std::fmt::Debug,

{

    use std::cell::RefCell;

    use std::io::{stdin, BufRead, StdinLock};

    thread_local! {

        pub static STDIN: RefCell<StdinLock<'static>> = RefCell::new(stdin().lock());

    }

    STDIN.with(|r| {

        let mut r = r.borrow_mut();

        let mut s = vec![];

        loop {

            let buf = r.fill_buf().unwrap();

            if buf.is_empty() {

                break;

            }

            if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {

                s.extend_from_slice(&buf[..i]);

                r.consume(i + 1);

                if !s.is_empty() {

                    break;

                }

            } else {

                s.extend_from_slice(buf);

                let n = buf.len();

                r.consume(n);

            }

        }

        std::str::from_utf8(&s).unwrap().parse().unwrap()

    })

}

#[macro_export]

macro_rules! println {

        ($($arg:tt)*) => {

            $crate::alg::io::_with_stdout(|w| {

                use std::io::Write;

                std::writeln!(w, $($arg)*).unwrap()

            })

        };

    }

#[macro_export]

macro_rules! print {

        ($($arg:tt)*) => {

            $crate::alg::io::_with_stdout(|w| {

                use std::io::Write;

                std::write!(w, $($arg)*).unwrap()

            })

        };

    }

#[doc(hidden)]

pub fn _with_stdout<F>(f: F)

where

    F: FnOnce(&mut std::io::BufWriter<std::io::StdoutLock>),

{

    use std::cell::RefCell;

    use std::io::{stdout, BufWriter, StdoutLock};

    thread_local! {

        pub static STDOUT: RefCell<BufWriter<StdoutLock<'static>>> =

            RefCell::new(BufWriter::new(stdout().lock()));

    }

    STDOUT.with(|w| f(&mut w.borrow_mut()))

}

}

}

// https://codeforces.com/contest/2049/problem/C

#[allow(unused_imports)]

use alg::io::read;

fn main() {

    for _ in 0..read() {

        solve();

    }

}

fn solve() {

    input! {

        n: usize,

        x: usize,

        y: usize,

    }

    let a = ring(n, x, y);

    for i in 0..n {

        print!("{} ", a[i]);

    }

    println!();

}

fn ring(n: usize, x: usize, y: usize) -> Vec<usize> {

    let x = x - 1;

    let y = y - 1;

    assert!(x < y);

    let mut a = vec![3; n];

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

        a[0] = n % 2 + 1;

        for i in 1..n {

            a[i] = (a[i - 1] + 1) % 2;

        }

        return a;

    }

    let l1 = y - x + 1;

    let l2 = x + n - y + 1;

    if n == 4 {

        a[(x + n - 1) % n] = 1;

        a[x] = 2;

        a[x + 1] = 1;

        a[y] = 0;

    } else {

        a[(x + n - 1) % n] = l2 % 2 + 1;

        a[x] = 0;

        a[x + 1] = l1 % 2 + 1;

        a[y] = 1;

    }

    for i in (x + 2)..y {

        a[i] = (a[i - 1] + 1) % 2;

    }

    for i in (y + 1)..(n + x - 1) {

        a[i % n] = (a[(i - 1) % n] + 1) % 2;

    }

    a

}

#[cfg(test)]

mod tests {

    use super::*;

    fn mex(a: &[usize]) -> usize {

        for i in 0.. {

            if !a.iter().any(|&e| e == i) {

                return i;

            }

        }

        unreachable!()

    }

    fn check(n: usize, x: usize, y: usize) {

        let a = ring(n, x, y);

        let x = x - 1;

        let y = y - 1;

        for i in 0..n {

            let mut tmp = vec![a[(i + 1) % n], a[(i + n - 1) % n]];

            if i == x {

                tmp.push(a[y]);

            } else if i == y {

                tmp.push(a[x]);

            }

            assert_eq!(a[i], mex(&tmp), "{i} {a:?}");

        }

    }

    #[test]

    fn test1() {

        check(5, 1, 3);

        check(4, 2, 4);

    }

    #[test]

    fn test2() {

        for n in 3..10 {

            for x in 1..n {

                for y in x + 1..=n {

                    check(n, x, y);

                }

            }

        }

    }

}

mod alg {

pub mod io {

#[macro_export]

macro_rules! input {

    (mut $var:ident: $kind:tt, $($rest:tt)*) => {

        let mut $var = $crate::_input_kind!($kind);

        input!($($rest)*)

    };

    ($var:ident: $kind:tt, $($rest:tt)*) => {

        let $var = $crate::_input_kind!($kind);

        input!($($rest)*)

    };

    (mut $var:ident: $kind:tt) => { let mut $var = $crate::_input_kind!($kind); };

    ($var:ident: $kind:tt) => { let $var = $crate::_input_kind!($kind); };

    () => {};

}

#[doc(hidden)]

#[macro_export]

macro_rules! _input_kind {

    ([$t:tt; $n:expr]) => {

        (0..$n).map(|_| $crate::_input_kind!($t)).collect::<Vec<_>>()

    };

    ([$t:tt]) => {{

        let n = $crate::_input_kind!(usize);

        (0..n).map(|_| $crate::_input_kind!($t)).collect::<Vec<_>>()

    }};

    (($a:tt, $b:tt)) => {{

        let a = $crate::_input_kind!($a);

        let b = $crate::_input_kind!($b);

        (a, b)

    }};

    (bytes) => {

        $crate::_input_kind!(String).into_bytes()

    };

    (usize1) => {

        $crate::_input_kind!(usize) - 1

    };

    ($t:ty) => {

        $crate::alg::io::read::<$t>()

    };

}

pub fn read<T>() -> T

where

    T: std::str::FromStr,

    T::Err: std::fmt::Debug,

{

    use std::cell::RefCell;

    use std::io::{stdin, BufRead, StdinLock};

    thread_local! {

        pub static STDIN: RefCell<StdinLock<'static>> = RefCell::new(stdin().lock());

    }

    STDIN.with(|r| {

        let mut r = r.borrow_mut();

        let mut s = vec![];

        loop {

            let buf = r.fill_buf().unwrap();

            if buf.is_empty() {

                break;

            }

            if let Some(i) = buf.iter().position(u8::is_ascii_whitespace) {

                s.extend_from_slice(&buf[..i]);

                r.consume(i + 1);

                if !s.is_empty() {

                    break;

                }

            } else {

                s.extend_from_slice(buf);

                let n = buf.len();

                r.consume(n);

            }

        }

        std::str::from_utf8(&s).unwrap().parse().unwrap()

    })

}

#[macro_export]

macro_rules! println {

        ($($arg:tt)*) => {

            $crate::alg::io::_with_stdout(|w| {

                use std::io::Write;

                std::writeln!(w, $($arg)*).unwrap()

            })

        };

    }

#[macro_export]

macro_rules! print {

        ($($arg:tt)*) => {

            $crate::alg::io::_with_stdout(|w| {

                use std::io::Write;

                std::write!(w, $($arg)*).unwrap()

            })

        };

    }

#[doc(hidden)]

pub fn _with_stdout<F>(f: F)

where

    F: FnOnce(&mut std::io::BufWriter<std::io::StdoutLock>),

{

    use std::cell::RefCell;

    use std::io::{stdout, BufWriter, StdoutLock};

    thread_local! {

        pub static STDOUT: RefCell<BufWriter<StdoutLock<'static>>> =

            RefCell::new(BufWriter::new(stdout().lock()));

    }

    STDOUT.with(|w| f(&mut w.borrow_mut()))

}

}

}

Answer: 2


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

}

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


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

void solve() {

    int n, x, y;

    cin>>n>>x>>y;

    vector<vector<int>> adj(n+1);

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

        int a = i+1>n?1:i+1;

        adj[i].push_back(a);

        int b = i-1<1?5:i-1;

        adj[i].push_back(b);

        if(i==x) adj[i].push_back(y);

        else if(i == y) adj[i].push_back(x);

    }

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

    queue<int> q;

    q.push(1);

    visited[1] = 0;

    bool m = false;

    while(!q.empty()){

        int node = q.front();

        q.pop();

        m = !m;

        for(auto nnode: adj[node]){

            if(visited[nnode] == -1) {

                visited[nnode] = m;

                q.push(nnode);

            }

        }

    }

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

        bool found2 = false;

        bool same = false;

        for(auto nnode: adj[i]){

            if(visited[i] == visited[nnode]) same = true;

            else if(visited[nnode] == 2) found2 = true;

        }

        if(!found2 and same) visited[i] = 2;

        cout<<visited[i]<<" ";

    }

    cout<<endl;

    return;

}

int main() {

    // Uncomment for local debugging

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

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

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

void solve() {

    int n, x, y;

    cin>>n>>x>>y;

    vector<vector<int>> adj(n+1);

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

        int a = i+1>n?1:i+1;

        adj[i].push_back(a);

        int b = i-1<1?5:i-1;

        adj[i].push_back(b);

        if(i==x) adj[i].push_back(y);

        else if(i == y) adj[i].push_back(x);

    }

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

    queue<int> q;

    q.push(1);

    visited[1] = 0;

    bool m = false;

    while(!q.empty()){

        int t = q.size();

        m = !m;

        while(t--){

            int node = q.front();

            q.pop();

            for(auto nnode: adj[node]){

                if(visited[nnode] == -1) {

                    visited[nnode] = m;

                    q.push(nnode);

                }

            }

        }

    }

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

        bool found2 = false;

        bool same = false;

        for(auto nnode: adj[i]){

            if(visited[i] == visited[nnode]) same = true;

            else if(visited[nnode] == 2) found2 = true;

        }

        if(!found2 and same) visited[i] = 2;

        cout<<visited[i]<<" ";

    }

    cout<<endl;

    return;

}

int main() {

    // Uncomment for local debugging

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

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

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

Answer: 2


#include <ios>

#include <iostream>

#include <vector>

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin >> t;

    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);

        int value = 0;

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

            a[i] = value;

            value = (value + 1) % 2;

        }

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

            a[x] = 2;

        }

        std::vector<int> result(n);

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

            result[i % n] = a[i];

        }

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

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

#include <ios>

#include <iostream>

#include <vector>

using namespace std;

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin >> t;

    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);

        int value = 0;

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

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }

        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

            if (a[x + n - 2] == 2) {

                a[x + n - 2] = 0;

            }

        }

        std::vector<int> result(n);

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

            result[i % n] = a[i];

        }

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

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Answer: 1


for _ in range(int(input())):

	n,x,y=map(int,input().split())

	t=[0]*n

	x=x-1

	y=y-1

	x1=min(x,y)

	x2=max(x,y)

	cluster1=x2-x1-1

	cluster2=n-(x2-x1-1)

	pos1=-1

	pos2=-1

	if cluster1%2==1 :

		pos1=(x2+x1)//2

	if cluster2%2==1:

		pos2=((x1+x2+n)//2)%n

	hattan=0

	for i in range(n):

		if i!=pos1 and i!=pos2:

			t[i]=str(hattan)

			hattan=(hattan+1)%2

		else:

			t[i]="2"

	print(" ".join(t))

for _ in range(int(input())):

	n,x,y=map(int,input().split())

	t=[0]*n

	x1=min(x,y)

	x2=max(x,y)

	cluster1=x2-x1-1

	cluster2=n-(x2-x1-1)

	pos1=-1

	pos2=-1

	if cluster1%2==1 :

		pos1=(x2+x1)//2

	if cluster2%2==1:

		pos2=((x1+x2+n)//2)%n

	hattan=0

	for i in range(n):

		if i!=pos1 and i!=pos2:

			t[i]=str(hattan)

			hattan=(hattan+1)%2

		else:

			t[i]="2"

	print(" ".join(t))

Answer: 1


// بسم الله الرحمن الرحيم

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

#define Hesham ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

//#define ordered_set tree<ll,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>

#define fll(i,a,b) for(long long i=a;i<b;i++)

#define fllm(i,a,b) for(long long i=a;i>=b;i--)

#define f(b,a) cout << fixed << setprecision(b) << a << endl;

#define rall(x) x.rbegin(),x.rend()

#define MOD 1000000007

#define sub_mod(a,b,m) ((((a)%m)-((b)%m)+m)%m)

#define add_mod(a,b,m) ((((a)%m)+((b)%m))%m)

#define mult_mod(a,b,m) ((((a)%m)*((b)%m))%m)

#define pi 3.14159265358979323846

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

#define ull unsigned long long

#define ld long double

#define ll long long

#define sz(s) s.size()

#define yes cout << "YES" << nl

#define no cout << "NO" << nl

#define F first

#define S second

#define nl '\n'

using namespace std;

//using namespace __gnu_pbds;

const int m=998244353;

const int maxn=200000;

vector<ll>fact(maxn,1),inv(maxn,1);

vector<bool>sieve(20+1,1);

vector<ll>spf(20);

ll dx[] = {0, -1, 1, 0};

ll dy[] = {1, 0, 0, -1};

bool isPrime(ll n)

{

    if(n==1||(n%2==0&&n!=2)) return false;

    for(ll j=2;j*j<=n;j++)

    {

        if(n%j==0)

        {

            return false;

        }

    }

    return true;

}

void sev()

{

    for(ll i=2;i*i<=maxn;i++)

    {

        if(sieve[i])

        {

            for(ll j=i*i;j<=maxn;j+=i)

            {

                sieve[j]=0;

            }

        }

    }

    sieve[1]=0,sieve[0]=0;

}

void smallestpf()

{

    spf[1]=1;

    fll(i,2,maxn) spf[i]=i;

    for(ll i=4;i<maxn;i+=2) spf[i]=2;

    for(ll i=3;i*i<maxn;i++)

    {

        if(spf[i]==i)

        {

            for(ll j=i*i;j<maxn;j+=i)

                if(spf[j]==j) spf[j]=i;

        }

    }

}

vector<ll>getf(ll n)

{

    vector<ll>ret;

    while(n!=1)

    {

        ret.push_back(spf[n]);

        n=n/spf[n];

    }

    return ret;

}

bool comp(pair<ll,ll>p1,pair<ll,ll>p2)

{

    return p1.S<p2.S;

}

ll fastpower(ll x,ll n,ll m)

{

    ll res=1;

    while(n>0)

    {

        if(n%2!=0) res=(res%m*x%m)%m,n--;

        else x=(x%m*x%m)%m,n/=2;

    }

    return res;

}

vector<ll>presum(vector<ll> &v)

{

    vector<ll>p(v.size());

    fll(i,0,v.size())

    {

        if(i==0) p[i]=v[i];

        else p[i]=v[i]+p[i-1];

    }

    return p;

}

vector<ll>primefactor(ll n)

{

    ll cn=0; vector<ll>v;

    while(n%2==0)

    {

        v.push_back(2); n/=2;

    }

    for(ll j=3;j*j<=n;j+=2)

    {

        while(n%j==0)

        {

            v.push_back(j);

            n/=j;

        }

    }

    if(n>2) v.push_back(n);

    return v;

}

vector<ll>divisors(ll n)

{

    vector<ll>c;

    for(ll i=1;i*i<=n;i++)

    {

        if(n%i==0)

        {

            c.push_back(i);

            if(n/i!=i) c.push_back(n/i);

        }

    }

    return c;

}

ll lcm(ll a,ll b)

{

    ll k=(a*b)/__gcd(a,b);

    return k;

}

ll arteq(ll l,ll r,ll p)

{

    ll k=((r-l)/p)+1;

    ll h=k*(l*2+(k-1)*p); h/=2;

    return h;

}

ll binpow(ll a,ll b,ll p=m)

{

    ll res=1;

    while(b>0)

    {

        if(b&1) res*=a,res%=p;

        a*=a,a%=p;

        b>>=1;

    }

    return res;

}

void solve()

{

    ll n,x,y,cn=0; cin >> n >> x >> y; x--,y--; vector<ll>v(n);

    fll(i,0,n)

    {

        if(i==n-1) v[i]=2;

        else v[i]=i%2;

    }

    if(v[x]==v[y]) v[y]=2;

    fll(i,0,n)

    {

        ll a=i-1,b=i+1;

        if(b==n) b=0;

        if(a==-1) a=n-1;

        ll mn,mx,c=0; vector<ll>cx;

        if(i==x) cx={v[a],v[b],v[y]};

        else if(i==y) cx={v[a],v[b],v[x]};

        else cx={v[a],v[b]};

        sort(all(cx));

        fll(j,0,sz(cx)) if(c==cx[j]) c++;

        v[i]=c;

    }

    fll(i,0,n)

    {

        ll a=i-1,b=i+1;

        if(b==n) b=0;

        if(a==-1) a=n-1;

        ll mn,mx,c=0; vector<ll>cx;

        if(i==x) cx={v[a],v[b],v[y]};

        else if(i==y) cx={v[a],v[b],v[x]};

        else cx={v[a],v[b]};

        sort(all(cx));

        fll(j,0,sz(cx)) if(c==cx[j]) c++;

        v[i]=c;

    }

    fll(i,0,n) cout << v[i] << " "; cout << nl;

}

int main()

{

    Hesham;

    // freopen("army.in","r",stdin);

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

    ll t=1;

    cin >> t;

    while(t--) solve();

  return 0;

}

// بسم الله الرحمن الرحيم

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>

//#include <ext/pb_ds/tree_policy.hpp>

#define Hesham ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

//#define ordered_set tree<ll,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>

#define fll(i,a,b) for(long long i=a;i<b;i++)

#define fllm(i,a,b) for(long long i=a;i>=b;i--)

#define f(b,a) cout << fixed << setprecision(b) << a << endl;

#define rall(x) x.rbegin(),x.rend()

#define MOD 1000000007

#define sub_mod(a,b,m) ((((a)%m)-((b)%m)+m)%m)

#define add_mod(a,b,m) ((((a)%m)+((b)%m))%m)

#define mult_mod(a,b,m) ((((a)%m)*((b)%m))%m)

#define pi 3.14159265358979323846

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

#define ull unsigned long long

#define ld long double

#define ll long long

#define sz(s) s.size()

#define yes cout << "YES" << nl

#define no cout << "NO" << nl

#define F first

#define S second

#define nl '\n'

using namespace std;

//using namespace __gnu_pbds;

const int m=998244353;

const int maxn=200000;

vector<ll>fact(maxn,1),inv(maxn,1);

vector<bool>sieve(20+1,1);

vector<ll>spf(20);

ll dx[] = {0, -1, 1, 0};

ll dy[] = {1, 0, 0, -1};

bool isPrime(ll n)

{

    if(n==1||(n%2==0&&n!=2)) return false;

    for(ll j=2;j*j<=n;j++)

    {

        if(n%j==0)

        {

            return false;

        }

    }

    return true;

}

void sev()

{

    for(ll i=2;i*i<=maxn;i++)

    {

        if(sieve[i])

        {

            for(ll j=i*i;j<=maxn;j+=i)

            {

                sieve[j]=0;

            }

        }

    }

    sieve[1]=0,sieve[0]=0;

}

void smallestpf()

{

    spf[1]=1;

    fll(i,2,maxn) spf[i]=i;

    for(ll i=4;i<maxn;i+=2) spf[i]=2;

    for(ll i=3;i*i<maxn;i++)

    {

        if(spf[i]==i)

        {

            for(ll j=i*i;j<maxn;j+=i)

                if(spf[j]==j) spf[j]=i;

        }

    }

}

vector<ll>getf(ll n)

{

    vector<ll>ret;

    while(n!=1)

    {

        ret.push_back(spf[n]);

        n=n/spf[n];

    }

    return ret;

}

bool comp(pair<ll,ll>p1,pair<ll,ll>p2)

{

    return p1.S<p2.S;

}

ll fastpower(ll x,ll n,ll m)

{

    ll res=1;

    while(n>0)

    {

        if(n%2!=0) res=(res%m*x%m)%m,n--;

        else x=(x%m*x%m)%m,n/=2;

    }

    return res;

}

vector<ll>presum(vector<ll> &v)

{

    vector<ll>p(v.size());

    fll(i,0,v.size())

    {

        if(i==0) p[i]=v[i];

        else p[i]=v[i]+p[i-1];

    }

    return p;

}

vector<ll>primefactor(ll n)

{

    ll cn=0; vector<ll>v;

    while(n%2==0)

    {

        v.push_back(2); n/=2;

    }

    for(ll j=3;j*j<=n;j+=2)

    {

        while(n%j==0)

        {

            v.push_back(j);

            n/=j;

        }

    }

    if(n>2) v.push_back(n);

    return v;

}

vector<ll>divisors(ll n)

{

    vector<ll>c;

    for(ll i=1;i*i<=n;i++)

    {

        if(n%i==0)

        {

            c.push_back(i);

            if(n/i!=i) c.push_back(n/i);

        }

    }

    return c;

}

ll lcm(ll a,ll b)

{

    ll k=(a*b)/__gcd(a,b);

    return k;

}

ll arteq(ll l,ll r,ll p)

{

    ll k=((r-l)/p)+1;

    ll h=k*(l*2+(k-1)*p); h/=2;

    return h;

}

ll binpow(ll a,ll b,ll p=m)

{

    ll res=1;

    while(b>0)

    {

        if(b&1) res*=a,res%=p;

        a*=a,a%=p;

        b>>=1;

    }

    return res;

}

void solve()

{

    ll n,x,y,cn=0; cin >> n >> x >> y; x--,y--; vector<ll>v(n);

    fll(i,0,n)

    {

        if(i==n-1) v[i]=2;

        else v[i]=i%2;

    }

    if(v[x]==v[y]) v[y]=2;

    fll(i,0,n)

    {

        ll a=i-1,b=i+1;

        if(b==n) b=0;

        if(a==-1) a=n-1;

        ll mn,mx,c=0; vector<ll>cx;

        if(i==x) cx={v[a],v[b],v[y]};

        else if(i==y) cx={v[a],v[b],v[x]};

        else cx={v[a],v[b]};

        sort(all(cx));

        fll(j,0,sz(cx)) if(c==cx[j]) c++;

        v[i]=c;

    }

    fll(i,0,n) cout << v[i] << " "; cout << nl;

}

int main()

{

    Hesham;

    // freopen("army.in","r",stdin);

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

    ll t=1;

    cin >> t;

    while(t--) solve();

  return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--; y--;

    vector<int> a(n, -1);

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

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

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

    }

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

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

    }

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

        cout << a[i] << " \n"[i == n - 1];

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) solve();

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

void solve() {

    int n, x, y;

    cin >> n >> x >> y;

    x--; y--;

    vector<int> a(n);

    a[x] = 0;

    a[y] = 1;

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

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

        if ((i + 1) % n == y && a[i] == 1) {

            a[i] = 2;

        }

    }

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

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

        if ((i - 1 + n) % n == y && a[i] == 1) {

            a[i] = 2;

        }

    }

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

        cout << a[i] << " \n"[i == n - 1];

    }

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) solve();

    return 0;

}

Answer: 2


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

}

#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=0;i<n;i++)

        {

            a[i]=i%2;

        }

        if(n%2==0 && x%2==y%2)

        {

            a[x-1]=2;

        }

        else if(x%2==y%2)

        {

            a[x-1]=2;a[0]=2;

        }

        else if(n%2)

        {

            a[0]=2;

        }

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

        {

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

        }

        cout<<'\n';

    }

    return 0;

}

Answer: 1


#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){

		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||i==y){

				cout<<2<<" ";

				continue;

			}

			t^=1;

			cout<<t<<" ";

		}

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

	}

}

int main(){

	cin>>t;

	while (t--) solve();

	return 0;

}

Answer: 1


#include<bits/stdc++.h>

// g++-14 -o main [file].cpp;

//./main < input.txt > output.txt

using namespace std;

#pragma region

#define ll long long

template<typename T>

void print(T v[], int n, int i = 0){

    for(; i < n; ++i){

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

    }

    cout << endl;

}

template<typename T>

void print(vector<T> v){

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

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

    }

    cout << endl;

}

ll inv_mod_prime(ll a, ll MOD) {

  return a <= 1 ? a : MOD - (MOD/a) * inv_mod_prime(MOD % a, MOD) % MOD;

}

// count number of bits

// only for int64 and int32

//__builtin_popcount

// bool is_prime[4'00'001];

// void sieve(int n){

//     memset(is_prime, true, sizeof(is_prime));

//     is_prime[0] = is_prime[1] = false;

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

//         is_prime[i] = false;

//     }

//     for(int i = 9; i <= n; i += 6){

//         is_prime[i] = false;

//     }

//     for(int i = 15; i <= n; i += 10){

//         is_prime[i] = false;

//     }

//     int num = 7;

//     while(num  <= n){

//         if(is_prime[num]){

//             for(int i = num+num; i <= n; i += num){

//                 is_prime[i] = false;

//             }

//         }

//         num += 2;

//     }

// }

#pragma endregion

int a[2'00'001];

int n, x, y;

int convert_ind(int i){

    if(i == 0) return n;

    if(i == n+1) return 1;

    return i;

}

void solve(){

    cin >> n >> x >> y;

    int start = x;

    int diff = y-x;

    int rev_diff = n-diff;

    int val = 0;

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

        a[i] = val;

        val ^= 1;

    }

    if(diff%2 == 0){

        a[convert_ind(y-1)] = 2;

        a[y] = 1;

    }

    int ind = x;

    val = 0;

    while(ind != y){

        a[ind] = val;

        val ^= 1;

        ind--;

        ind = convert_ind(ind);

    }

    if(rev_diff%2 == 0){

        a[convert_ind(y+1)] = 2;

        a[y] = 1;

    }

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

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

    }

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

#include<bits/stdc++.h>

// g++-14 -o main [file].cpp;

//./main < input.txt > output.txt

using namespace std;

#pragma region

#define ll long long

template<typename T>

void print(T v[], int n, int i = 0){

    for(; i < n; ++i){

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

    }

    cout << endl;

}

template<typename T>

void print(vector<T> v){

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

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

    }

    cout << endl;

}

ll inv_mod_prime(ll a, ll MOD) {

  return a <= 1 ? a : MOD - (MOD/a) * inv_mod_prime(MOD % a, MOD) % MOD;

}

// count number of bits

// only for int64 and int32

//__builtin_popcount

// bool is_prime[4'00'001];

// void sieve(int n){

//     memset(is_prime, true, sizeof(is_prime));

//     is_prime[0] = is_prime[1] = false;

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

//         is_prime[i] = false;

//     }

//     for(int i = 9; i <= n; i += 6){

//         is_prime[i] = false;

//     }

//     for(int i = 15; i <= n; i += 10){

//         is_prime[i] = false;

//     }

//     int num = 7;

//     while(num  <= n){

//         if(is_prime[num]){

//             for(int i = num+num; i <= n; i += num){

//                 is_prime[i] = false;

//             }

//         }

//         num += 2;

//     }

// }

#pragma endregion

int a[2'00'001];

int n, x, y;

int convert_ind(int i){

    if(i == 0) return n;

    if(i == n+1) return 1;

    return i;

}

void solve(){

    cin >> n >> x >> y;

    int start = x;

    int diff = y-x;

    int rev_diff = n-diff;

    int val = 0;

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

        a[i] = val;

        val ^= 1;

    }

    if(diff%2 == 0){

        a[convert_ind(y-1)] = 2;

        a[y] = 1;

    }

    int ind = x;

    val = 0;

    while(ind != y){

        a[ind] = val;

        val ^= 1;

        ind--;

        ind = convert_ind(ind);

    }

    if(rev_diff%2 == 0){

        a[convert_ind(y+1)] = 2;

        a[y] = 1;

    }

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

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

    }

    cout << endl;

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

Answer: 1


 #include<bits/stdc++.h>

#define ll long long int

using namespace std;

int main(){

    ll t;

    cin>>t;

    while(t--){

        ll n,x,y;

        cin>>n>>x>>y;

        vector<ll>v(n,0);

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

            if(i%2!=0) v[i]=1;

        }

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

        for(int i=0;i<=n-1;i++) cout<<v[i]<<" ";

        cout<<endl;

    }

    return 0;

}

 #include<bits/stdc++.h>

#define ll long long int

using namespace std;

int main(){

    ll t;

    cin>>t;

    while(t--){

        ll n,x,y;

        cin>>n>>x>>y;

        vector<ll>v(n,0);

        --x;

        --y;

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

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

        }

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

        for(int i=0;i<=n-1;i++) cout<<v[i]<<" ";

        cout<<endl;

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define vi vector<int>

#define pii pair<int,int>

#define vpii vector<pair<int,int>>

#define pb push_back

#define f first

#define s second

const ll MOD = 1e9+7;

ll gcd(ll a, ll b) {

    if (a == 0) return b;

    return gcd(b % a, a);

}

ll pow(ll x, ll n) {

    if (n == 0) return 1;

    if (n % 2 == 0) return pow((x * x) % MOD, n / 2);

    return (x * pow((x * x) % MOD, (n - 1) / 2) % MOD);

}

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

    int p[n+2]={0};

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

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

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

    }

    else {

        // x --> y ==> (y-x-1)

        // both side even => 0 - 1 => 1 0 1 0

        // else => odd side => 1 0 1 1 0 10 0

        int curr = 1;

        p[x]=0;

        p[y]=2;

        for(int i=x+1; i<y; i++) p[i] = p[i-1]^1; // x+1 ->y

        for(int i=x-1; i>=1; i--) p[i] = p[i+1]^1; // 1 -> x-1

        for(int i=n; i>y; i--) p[i] = p[(i+1)%n ==0 ? n : (i+1)%n]^1;// y+1 -> n

        if((y-x -1 )%2 == 0 && (n-y+x-1)%2 == 0) p[y]=1;

    }

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

    cout<<"\n";

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t=1;

    cin>>t;

    for(int i=01;i<=t;i++) {

        // cout<<"Case #"<<i<<"\n";

        solve();

    }

    return 0;

}

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define vi vector<int>

#define pii pair<int,int>

#define vpii vector<pair<int,int>>

#define pb push_back

#define f first

#define s second

const ll MOD = 1e9+7;

ll gcd(ll a, ll b) {

    if (a == 0) return b;

    return gcd(b % a, a);

}

ll pow(ll x, ll n) {

    if (n == 0) return 1;

    if (n % 2 == 0) return pow((x * x) % MOD, n / 2);

    return (x * pow((x * x) % MOD, (n - 1) / 2) % MOD);

}

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

        int dem = 2 + n%2;

        for(int i=0; i<n; i++) cout<<(i%dem)<<" ";

        cout<<"\n";

        return;

    }

    // x --> y ==> (y-x-1)

    // both side even => 0 - 1 => 1 0 1 0

    // else => odd side => 1 0 1 1 0 10 0

    int p[n+2]={0};

    int curr = 1;

    p[x]=0;

    p[y]=2;

    for(int i=x+1; i<y; i++) p[i] = p[i-1]^1; // x+1 ->y

    for(int i=x-1; i>=1; i--) p[i] = p[i+1]^1; // 1 -> x-1

    for(int i=n; i>y; i--) p[i] = p[(i+1)%n ==0 ? n : (i+1)%n]^1;// y+1 -> n

    if((y-x -1 )%2 == 0 && (n-y+x-1)%2 == 0) p[y]=1;

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

    cout<<"\n";

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t=1;

    cin>>t;

    for(int i=01;i<=t;i++) {

        // cout<<"Case #"<<i<<"\n";

        solve();

    }

    return 0;

}

Answer: 1


#include <iostream>

#include <vector>

#include <string>

#include <sstream>

#include <fstream>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <map>

#include <bitset>

#include <numeric>

#include <set>

#include <queue>

#include <unordered_map>

#include <cassert>

#include <array>

#include <deque>

#include <functional>

using namespace std;

#define NDEBUG

#define endl "\n"

#define ff first

#define ss second

#define vi vector<int>

#define pii pair<int, int>

#define sz(x) (int)x.size()

//#define int long long

constexpr int MAX_N = 100'005;

constexpr int INF = 1E9;

int32_t main() {

    // ifstream cin("MEXcycle.txt");

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    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[(x + i) % n] = i % 2;

        }

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

            ans[x] = 2;

        }

        for (auto& i : ans) cout<<i<<" ";

        cout<<endl;

    }

}

#include <iostream>

#include <vector>

#include <string>

#include <sstream>

#include <fstream>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <map>

#include <bitset>

#include <numeric>

#include <set>

#include <queue>

#include <unordered_map>

#include <cassert>

#include <array>

#include <deque>

#include <functional>

using namespace std;

#define NDEBUG

#define endl "\n"

#define ff first

#define ss second

#define vi vector<int>

#define pii pair<int, int>

#define sz(x) (int)x.size()

//#define int long long

constexpr int MAX_N = 100'005;

constexpr int INF = 1E9;

int32_t main() {

    // ifstream cin("MEXcycle.txt");

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int t; cin>>t;

    while(t--) {

        int n, x, y;

        cin>>n>>x>>y;

        vector<int> ans;

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

            if (i % 2) ans.push_back(0);

            else ans.push_back(1);

        }

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

            ans[x - 1] = 2;

        }

        else if (n % 2) {

            ans[0] = 2;

        }

        for (auto& i : ans) cout<<i<<" ";

        cout<<endl;

    }

}

Answer: 1


#include <bits/stdc++.h>

const int N = 200100;

int n, x, y;

int a[N];

int calc(std::vector<int> element) {

    for (int mex = 0;; mex ++) {

        bool flag = 0;

        for (int x : element)

            if (x == mex) {

                flag = 1;

                break;

            }

        if (!flag)

            return mex;

    }

}

void work() {

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

    a[x] = a[y] = -1;

    int state = 1;

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

        a[i] = (state ^= 1);

    state = 1;

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

        a[i] = (state ^= 1);

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

        a[i] = (state ^= 1);

    a[x] = calc({a[x == 1 ? n : x - 1], a[x == n ? 1 : x + 1]});

    a[y] = calc({a[y == 1 ? n : y - 1], a[y == n ? 1 : y + 1], a[x]});

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

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

    std::cout << '\n';

}

int main() {

    std::ios::sync_with_stdio(0);

    std::cin.tie(0);

    int T;

    std::cin >> T;

    while (T --)

        work();

    return 0;

}

/*

 *  心中无女人

 *  比赛自然神

 *  模板第一页

 *  忘掉心上人

**/

#include <bits/stdc++.h>

const int N = 200100;

int n, x, y;

int a[N];

int calc(std::vector<int> element) {

    for (int mex = 0;; mex ++) {

        bool flag = 0;

        for (int x : element)

            if (x == mex) {

                flag = 1;

                break;

            }

        if (!flag)

            return mex;

    }

}

void work() {

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

    a[x] = a[y] = -1;

    int state = 0;

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

        a[i] = (state ^= 1);

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

        a[i] = (state ^= 1);

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

        a[i] = (state ^= 1);

    a[x] = calc({a[x == 1 ? n : x - 1], a[x == n ? 1 : x + 1]});

    a[y] = calc({a[y == 1 ? n : y - 1], a[y == n ? 1 : y + 1], a[x]});

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

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

    std::cout << '\n';

}

int main() {

    std::ios::sync_with_stdio(0);

    std::cin.tie(0);

    int T;

    std::cin >> T;

    while (T --)

        work();

    return 0;

}

/*

 *  心中无女人

 *  比赛自然神

 *  模板第一页

 *  忘掉心上人

**/

Answer: 1


#include <bits/stdc++.h>

using namespace std;

void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    x--,y--;

    vector<int>a(n);

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

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

    }

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

        a[x]=2;

    }

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

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

    }

    cout<<"\n";

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    vector<int>a(n+1);

    a[1]=0;

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

        a[i]=(a[i-1]+1)%3;

    }

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

        a[y]=3-a[x]-a[y-1];

    }

    int z=(y+1)%n;

    if(a[z]==a[y]||a[z]==a[z+1]){

        a[z]=3-a[y]-a[z+1];

    }

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

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

    }

    cout<<"\n";

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

Answer: 1


#include <bits/stdc++.h>

#include <algorithm>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#pragma GCC optimize("Ofast")

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

#pragma GCC optimization("unroll-loops")

#define nl '\n'

#define sp ' '

#define pi 2 * acos(0.0)

// Types of declarations /////////////////////////////////

#define ui unsigned int

#define us unsigned short

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

#define ull unsigned long long

#define ll long long

#define ld long double

#define vstr vector<string>

#define vll vector<ll>

#define vi vector<int>

#define vvi vector<vector<int>>

#define vii vector<pair<int, int>>

#define pii pair<int, int>

// Odd Even /////////////////////////////////////////////

bool odd(ll num) { return ((num & 1) == 1); }

bool even(ll num) { return ((num & 1) == 0); }

//////////////////////////////////////////////////////// Prime

bool isPrime(int n)

{

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

    {

        if (n % i == 0)

            return false;

    }

    return true;

}

///////////////////////////////////////////////////////// LCM GCD

long long gcd(long long a, long long b)

{

    while (b != 0)

    {

        long long temp = b;

        b = a % b;

        a = temp;

    }

    return a;

}

long long lcm(long long a, long long b)

{

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

}

////////////////////////////////////////////////////////// SQR ROOT

long long sqrt(long long x)

{

    long long s = 0, e = 2e9, res = s;

    while (s <= e)

    {

        long long m = (s + e) / 2;

        if (m * m <= x)

            res = m, s = m + 1;

        else

            e = m - 1;

    }

    return res;

}

/*

    vi arr(n);

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

        cin>>arr[i];

*/

/*

check all edge cases

check for integer overflow

check for corner cases

check for constraints

check for time complexity

check for array bounds

check for negative values

*/

/*----------------------------------------------------------------------------*/

void solve()

{

    // Read input: n = number of dragons, x and y are the special dragons

    int n, x, y;

    cin >> n >> x >> y;

    // Convert x and y from 1-indexed to 0-indexed for array usage

    x--, y--;

    vector<int> a(n); // Array to store the assigned numbers for dragons

    if (n % 2 == 0)

    {

        // For even n, assign alternating values: 0, 1, 0, 1, ...

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

        {

            a[i] = i % 2;

        }

        // If dragons x and y (friends) have the same number, break the tie by changing one of them

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

        {

            a[x] = 2;  // New value to ensure mex condition holds on the cycle

        }

    }

    else

    {

        // For odd n, fix the value for dragon x to 2 first

        a[x] = 2;

        // For positions after x, use alternating pattern (0 and 1)

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

        {

            a[i] = i % 2;

        }

        // For positions before x, adjust pattern with (n + i) % 2 to maintain cyclic order

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

        {

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

        }

    }

    // Output the array where each entry represents dragon's assigned number

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

    {

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

    }

    cout << '\n';

}

/*

Evirir the dragon has many friends. They have 3 friends! That is one more than the average dragon.

You are given integers n

, x

, and y

. There are n

 dragons sitting in a circle. The dragons are numbered 1,2,…,n

. For each i

 (1≤i≤n

), dragon i

 is friends with dragon i−1

 and i+1

, where dragon 0

 is defined to be dragon n

 and dragon n+1

 is defined to be dragon 1

. Additionally, dragons x

 and y

 are friends with each other (if they are already friends, this changes nothing). Note that all friendships are mutual.

Output n

 non-negative integers a1,a2,…,an

 such that for each dragon i

 (1≤i≤n

), the following holds:

Let f1,f2,…,fk

 be the friends of dragon i

. Then ai=mex(af1,af2,…,afk)

.∗

∗

The minimum excluded (MEX) of a collection of integers c1,c2,…,cm

 is defined as the smallest non-negative integer t

 which does not occur in the collection c

.

Input

Each test contains multiple test cases. The first line contains the number of test cases t

 (1≤t≤104

). The description of the test cases follows.

The first and only line of each test case contains three integers n

, x

, y

 (3≤n≤2⋅105

, 1≤x<y≤n

).

It is guaranteed that the sum of n

 over all test cases does not exceed 2⋅105

.

Output

For each test case, output n

 space-separated non-negative integers a1,a2,…,an

 (0≤ai≤109

) on a line that satisfy the condition in the statement. If there are multiple solutions, print any of them. It can be proven that under the problem constraints, a solution with 0≤ai≤109

 always exists.

Example

InputCopy

7

5 1 3

4 2 4

6 3 5

7 3 6

3 2 3

5 1 5

6 2 5

OutputCopy

0 2 1 0 1

1 2 1 0

1 2 0 1 2 0

0 1 2 0 1 0 1

2 0 1

1 0 2 1 0

0 1 2 0 2 1

Note

For the first test case:

i=1

: Dragon 1

's friends are dragons 2,3,5

. mex(a2,a3,a5)=mex(2,1,1)=0=a1

, so the condition for dragon 1

 is satisfied.

i=2

: Dragon 2

's friends are dragons 1,3

. mex(a1,a3)=mex(0,1)=2=a2

.

i=3

: Dragon 3

's friends are dragons 1,2,4

. mex(a1,a2,a4)=mex(0,2,0)=1=a3

.

i=4

: Dragon 4

's friends are dragons 3,5

. mex(a3,a5)=mex(1,1)=0=a4

.

i=5

: Dragon 5

's friends are dragons 1,4

. mex(a1,a4)=mex(0,0)=1=a5

.

 */

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

}

#include <bits/stdc++.h>

#include <algorithm>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#pragma GCC optimize("Ofast")

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

#pragma GCC optimization("unroll-loops")

#define nl '\n'

#define sp ' '

#define pi 2 * acos(0.0)

// Types of declarations /////////////////////////////////

#define ui unsigned int

#define us unsigned short

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

#define ull unsigned long long

#define ll long long

#define ld long double

#define vstr vector<string>

#define vll vector<ll>

#define vi vector<int>

#define vvi vector<vector<int>>

#define vii vector<pair<int, int>>

#define pii pair<int, int>

// Odd Even /////////////////////////////////////////////

bool odd(ll num) { return ((num & 1) == 1); }

bool even(ll num) { return ((num & 1) == 0); }

//////////////////////////////////////////////////////// Prime

bool isPrime(int n)

{

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

    {

        if (n % i == 0)

            return false;

    }

    return true;

}

///////////////////////////////////////////////////////// LCM GCD

long long gcd(long long a, long long b)

{

    while (b != 0)

    {

        long long temp = b;

        b = a % b;

        a = temp;

    }

    return a;

}

long long lcm(long long a, long long b)

{

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

}

////////////////////////////////////////////////////////// SQR ROOT

long long sqrt(long long x)

{

    long long s = 0, e = 2e9, res = s;

    while (s <= e)

    {

        long long m = (s + e) / 2;

        if (m * m <= x)

            res = m, s = m + 1;

        else

            e = m - 1;

    }

    return res;

}

/*

    vi arr(n);

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

        cin>>arr[i];

*/

/*

check all edge cases

check for integer overflow

check for corner cases

check for constraints

check for time complexity

check for array bounds

check for negative values

*/

/*----------------------------------------------------------------------------*/

void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> a(n);

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

        a[i] = i % 3;

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

        cout << a[i] << (i + 1 < n ? ' ' : '\n');

}

/*

Evirir the dragon has many friends. They have 3 friends! That is one more than the average dragon.

You are given integers n

, x

, and y

. There are n

 dragons sitting in a circle. The dragons are numbered 1,2,…,n

. For each i

 (1≤i≤n

), dragon i

 is friends with dragon i−1

 and i+1

, where dragon 0

 is defined to be dragon n

 and dragon n+1

 is defined to be dragon 1

. Additionally, dragons x

 and y

 are friends with each other (if they are already friends, this changes nothing). Note that all friendships are mutual.

Output n

 non-negative integers a1,a2,…,an

 such that for each dragon i

 (1≤i≤n

), the following holds:

Let f1,f2,…,fk

 be the friends of dragon i

. Then ai=mex(af1,af2,…,afk)

.∗

∗

The minimum excluded (MEX) of a collection of integers c1,c2,…,cm

 is defined as the smallest non-negative integer t

 which does not occur in the collection c

.

Input

Each test contains multiple test cases. The first line contains the number of test cases t

 (1≤t≤104

). The description of the test cases follows.

The first and only line of each test case contains three integers n

, x

, y

 (3≤n≤2⋅105

, 1≤x<y≤n

).

It is guaranteed that the sum of n

 over all test cases does not exceed 2⋅105

.

Output

For each test case, output n

 space-separated non-negative integers a1,a2,…,an

 (0≤ai≤109

) on a line that satisfy the condition in the statement. If there are multiple solutions, print any of them. It can be proven that under the problem constraints, a solution with 0≤ai≤109

 always exists.

Example

InputCopy

7

5 1 3

4 2 4

6 3 5

7 3 6

3 2 3

5 1 5

6 2 5

OutputCopy

0 2 1 0 1

1 2 1 0

1 2 0 1 2 0

0 1 2 0 1 0 1

2 0 1

1 0 2 1 0

0 1 2 0 2 1

Note

For the first test case:

i=1

: Dragon 1

's friends are dragons 2,3,5

. mex(a2,a3,a5)=mex(2,1,1)=0=a1

, so the condition for dragon 1

 is satisfied.

i=2

: Dragon 2

's friends are dragons 1,3

. mex(a1,a3)=mex(0,1)=2=a2

.

i=3

: Dragon 3

's friends are dragons 1,2,4

. mex(a1,a2,a4)=mex(0,2,0)=1=a3

.

i=4

: Dragon 4

's friends are dragons 3,5

. mex(a3,a5)=mex(1,1)=0=a4

.

i=5

: Dragon 5

's friends are dragons 1,4

. mex(a1,a4)=mex(0,0)=1=a5

.

 */

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

}

Answer: 1