#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define int long long

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

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

#define mp make_pair

const int N=1e7+10;

const int M=1e5+10;

//int pf[N];

long long binpow(long long a, long long b) {

    if(b==0)

        return 1;

    long long res = binpow(a,b/2);

    if(b%2)

        return res*res*a;

    else

        return res*res;

}

int mex(vector<int> &arr, int N){

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

    int mex = 0;

    for (int idx = 0; idx < N; idx++){

        if (arr[idx] == mex){

            mex += 1;

        }

    }

    return mex;

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        int n;cin>>n;

        string s;cin>>s;

        if(s[0]=='s') s[0]='.';

        if(s[n-1]=='p') s[n-1]='.';

        int flagp=0,flags=0;

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

            if(s[i]=='p') flagp=1;

            if(s[i]=='s') flags=1;

        }

        if(flagp && flags) cout<<"NO"<<endl;

        else cout<<"YES"<<endl;

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define int long long

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

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

#define mp make_pair

const int N=1e7+10;

const int M=1e5+10;

//int pf[N];

long long binpow(long long a, long long b) {

    if(b==0)

        return 1;

    long long res = binpow(a,b/2);

    if(b%2)

        return res*res*a;

    else

        return res*res;

}

int mex(vector<int> &arr, int N){

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

    int mex = 0;

    for (int idx = 0; idx < N; idx++){

        if (arr[idx] == mex){

            mex += 1;

        }

    }

    return mex;

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        int n;cin>>n;

        string s;cin>>s;

        int flag=0,fllag=0;

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

            if(s[i]=='p') flag=1;

            if(flag){

                if(s[i]=='s'){

                    fllag=1;break;

                }

            }

        }

        int presp=0,press=0;

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

            if(s[i]=='p') presp=1;

            else if(s[i]=='s') press=1;

        }

        if(fllag) cout<<"NO"<<endl;

        else if((press==1 && presp==1) && (s[0]=='.' && s[n-1]=='.')) cout<<"NO"<<endl;

        else cout<<"YES"<<endl;

    }

    return 0;

}

Answer: 1


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    // Check if the string contains 's' or 'p'
    if (s.find('s') == string::npos && s.find('p') == string::npos)
    {
        cout << "YES\n";
        return;
    }
    if (s[0] == 's') s[0] = '.';
    if (s.back() == 'p') s.back() = '.';
    bool fp = false, fs = false;
    f(i, 0, n)
    {
        switch (s[i])
        {
        case 's':
            fs = true;
            break;
        case 'p':
            fp = true;
            break;
        }
    }
    cout << (fs && fp ? "NO\n" : "YES\n");

    return;
}

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

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

    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll count_p = count(s.begin(), s.end(), 'p');
    ll count_s = count(s.begin(), s.end(), 's');
    if (count_p == 0 || count_s == 0){
        cout << "YES\n";
    }
    else {
        if (s[0] == 's' || s[n - 1] == 'p'){
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return;
}

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

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

    return 0;
}

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

    }

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long       ll;

typedef vector<int>     vi;

typedef vector<vi>      vvi;

typedef vector<ll>      vll;

typedef pair<int,int>   pii;

typedef pair<ll,ll>     pll;

typedef vector<pii>     vpii;

// #define rep(i,x,y)      for(int i=x; true; i=(i+1)%n)

#define rrep(i,x,y)     for(int i=x; i>=y; i--)

#define inp(arr)        for(auto &x: arr) cin >>x;

#define ninp(arr,n)     int n; cin >>n; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define kinp(arr,n,k)   int n,k; cin >>n >>k; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define out(arr)        for(auto &x: arr){ cout <<x <<' ';} cout <<endl;

#define EB              emplace_back

#define F               first

#define S               second

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

int main(){

    int t; cin >>t;

    while(t--){

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

        x--, y--;

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

        vi ans(n,0);

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

        int i=x, op = 0;

        while(1){

            // cout <<i <<" ";

            if((y==0 && i==n-1) || i==y-1){

                if(op==0) ans[i] = op;

                else ans[i] = 2;

                break;

            }

            ans[i] = op;

            op = 1 - op;

            i=(i+1)%n;

        }

        i=y, op = 1;

        // cout <<"\n";

        while(1){

            // cout <<i <<" ";

            if((x==0 && i==n-1) || i==x-1){

                if(op==0) ans[i]=2;

                else ans[i]=1;

                break;

            }

            ans[i] = op;

            op = 1 - op;

            i=(i+1)%n;

        }

        // cout <<"\n";

        out(ans);

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

typedef long long       ll;

typedef vector<int>     vi;

typedef vector<vi>      vvi;

typedef vector<ll>      vll;

typedef pair<int,int>   pii;

typedef pair<ll,ll>     pll;

typedef vector<pii>     vpii;

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

#define rrep(i,x,y)     for(int i=x; i>=y; i--)

#define inp(arr)        for(auto &x: arr) cin >>x;

#define ninp(arr,n)     int n; cin >>n; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define kinp(arr,n,k)   int n,k; cin >>n >>k; vector<int> arr(n); for(auto &x: arr) cin >>x;

#define out(arr)        for(auto &x: arr){ cout <<x <<' ';} cout <<endl;

#define EB              emplace_back

#define F               first

#define S               second

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

int main(){

    int t; cin >>t;

    while(t--){

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

        x--, y--;

        vi ans(n,0);

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

        rep(i,x+1,y){

            if(i==y-1){

                if(i%2 != x%2) ans[i]=2;

                else ans[i]=0;

                continue;

            }

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

            else ans[i]=1;

        }

        rep(i,y+1,x){

            if(i==x-1){

                if(i%2 != y%2) ans[i]=2;

                else ans[i]=1;

                continue;

            }

            if(i%2 == y%2) ans[i]=1;

            else ans[i]=0;

        }

        out(ans);

    }

    return 0;

}

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] = 2;

    ans[y] = 1;

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

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

    for (int i = y + 1; i < n + 1; i++) ans[i] = ans[i > 1 ? i - 1 : n] == 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] = (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 ^_^ (•‿•)

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

**/

Answer: 2


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

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

----------------------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(n + 1);

    int b = 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)

    {

        ans[y] = 2;

    };

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

    if (p & 1)

    {

        b = 1;

    }

    else

    {

        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;

        }

    }

    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----------------------------------------------->*/

Answer: 1


#include <bits/stdc++.h>

using namespace std;

int main() {

    long long input;

    cin >> input;

    for(long long i=0 ; i<input ; i++){

        int n,k,m;

        cin >> n >> k >> m;

        int minx=INT_MAX;

        vector<int> que(n,0);

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

            if(j==0){

                if(j+1==k){

                    if(que[j+1]==1 || que[n-j-1]==1 || que[m-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2 || que[m-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else if(j+1==m){

                    if(que[j+1]==1 || que[n-j-1]==1 || que[k-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2 || que[k-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else{

                    if(que[j+1]==1 || que[n-j-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

            }

            else if(j==n-1){

                if(j+1==k){

                    if(que[0]==1 || que[n-2]==1 || que[m-1]==1){

                        if(que[0]==2 || que[n-2]==2 || que[m-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else if(j+1==m){

                    if(que[0]==1 || que[n-2]==1 || que[k-1]==1){

                        if(que[0]==2 || que[n-2]==2 || que[k-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else{

                    if(que[0]==1 || que[n-2]==1){

                        if(que[0]==2 || que[n-2]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

            }

            else{

                if(j+1==k){

                    if(que[j+1]==1 || que[j-1]==1 || que[m-1]==1){

                        if(que[j+1]==2 || que[j-1]==2 || que[m-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else if(j+1==m){

                    if(que[j+1]==1 || que[j-1]==1 || que[k-1]==1){

                        if(que[j+1]==2 || que[j-1]==2 || que[k-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else{

                    if(que[j+1]==1 || que[j-1]==1){

                        if(que[j+1]==2 || que[j-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

            }

        }

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

            cout << que[j]-minx << " ";

        }

        cout << endl;

    }

}

#include <bits/stdc++.h>

using namespace std;

int main() {

    long long input;

    cin >> input;

    for(long long i=0 ; i<input ; i++){

        int n,k,m;

        cin >> n >> k >> m;

        int minx=INT_MAX;

        vector<int> que(n,0);

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

            if(j==0 || j==n-1){

                if(j+1==k){

                    if(que[j+1]==1 || que[n-j-1]==1 || que[m-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2 || que[m-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else if(j+1==m){

                    if(que[j+1]==1 || que[n-j-1]==1 || que[k-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2 || que[k-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else{

                    if(que[j+1]==1 || que[n-j-1]==1){

                        if(que[j+1]==2 || que[n-j-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

            }

            else{

                if(j+1==k){

                    if(que[j+1]==1 || que[j-1]==1 || que[m-1]==1){

                        if(que[j+1]==2 || que[j-1]==2 || que[m-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                if(j+1==m){

                    if(que[j+1]==1 || que[j-1]==1 || que[k-1]==1){

                        if(que[j+1]==2 || que[j-1]==2 || que[k-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

                else{

                    if(que[j+1]==1 || que[j-1]==1){

                        if(que[j+1]==2 || que[j-1]==2){

                            que[j]=3;

                            minx=min(minx,que[j]);

                        }

                        else{

                            que[j]=2;

                            minx=min(minx,que[j]);

                        }

                    }

                    else{

                        que[j]=1;

                        minx=min(minx,que[j]);

                    }

                }

            }

        }

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

            cout << que[j]-minx << " ";

        }

        cout << endl;

    }

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ull = unsigned long long;

using ld = long double;

#define double ld

#define int ll

#define MOD 1000000007

#define MOD1 998244353

#define INF 1e18

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define fi first

#define se second

#define vl vector<ll>

#define vvl vector<vl>

#define vb vector<bool>

#define vvb vector<vb>

#define vc vector<char>

#define vvc vector<vc>

#define vs vector<string>

#define pll pair<ll, ll>

#define vpll vector<pair<ll, ll>>

#define vvpll vector<vector<pair<ll, ll>>>

#define umll unordered_map<ll, ll>

#define umcl unordered_map<char, ll>

#define umlc unordered_map<ll, char>

#define fr(i, a, n) for (ll i = (a); i < (n); i++)

#define rfr(i, n, a) for (ll i = n; i >= a; i--)

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

#define allr(v) v.rbegin(), v.rend()

#define srt(v) sort(all(v))         // sort

#define mxe(v) *max_element(all(v)) // find max element in vector

#define mne(v) *min_element(all(v)) // find min element in vector

#define rev(v) reverse(all(v))

#define sum_arr(v) accumulate(all(v), 0LL)

#define pq_max priority_queue<int>

#define pq_min priority_queue<int, vector<int>, greater<int>>

#define yes cout << "YES" << "\n"

#define no cout << "NO" << "\n"

// function

ll gcd(ll a, ll b)

{

    if (a == 0)

        return b;

    return gcd(b % a, a);

}

ll ncr(ll n, ll r)

{

    ll res = 1;

    fr(i, 0, r)

    {

        res = res * (n - i);

        res = res / (i + 1);

    }

    return res;

}

int lcm(int a, int b)

{

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

}

vector<int> simpleSieve(int limit)

{

    vector<bool> is_prime(limit + 1, true);

    vector<int> primes;

    for (int p = 2; p <= limit; ++p)

    {

        if (is_prime[p])

        {

            primes.push_back(p);

            for (int multiple = p * p; multiple <= limit; multiple += p)

            {

                is_prime[multiple] = false;

            }

        }

    }

    return primes;

}

int primeinrange(int L, int R)

{

    int limit = sqrt(R);

    vector<int> primes = simpleSieve(limit);

    vector<bool> is_prime(R - L + 1, true);

    for (int prime : primes)

    {

        int start = max(prime * prime, (L + prime - 1) / prime * prime);

        for (int j = start; j <= R; j += prime)

        {

            is_prime[j - L] = false;

        }

    }

    if (L == 1)

        is_prime[0] = false;

    int c = 0;

    for (int i = 0; i <= R - L; ++i)

    {

        if (is_prime[i])

        {

            c++;

        }

    }

    return c;

}

int mod_exp(int base, int exp, int mod)

{

    int result = 1;

    while (exp > 0)

    {

        if (exp % 2 == 1)

        {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

// Code by harshsingh9222

int exp(int k,int c)

{

    return pow(k,c);

}

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

    x--,y--;

    vl a(n);

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

    {

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

    }

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

    {

        a[x]=2;

    }

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

    {

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

    }

    cout<<'\n';

}

signed main()

{

    ios_base ::sync_with_stdio(false);

    cin.tie(0);

    cout << setprecision(12) << fixed;

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ull = unsigned long long;

using ld = long double;

#define double ld

#define int ll

#define MOD 1000000007

#define MOD1 998244353

#define INF 1e18

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define fi first

#define se second

#define vl vector<ll>

#define vvl vector<vl>

#define vb vector<bool>

#define vvb vector<vb>

#define vc vector<char>

#define vvc vector<vc>

#define vs vector<string>

#define pll pair<ll, ll>

#define vpll vector<pair<ll, ll>>

#define vvpll vector<vector<pair<ll, ll>>>

#define umll unordered_map<ll, ll>

#define umcl unordered_map<char, ll>

#define umlc unordered_map<ll, char>

#define fr(i, a, n) for (ll i = (a); i < (n); i++)

#define rfr(i, n, a) for (ll i = n; i >= a; i--)

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

#define allr(v) v.rbegin(), v.rend()

#define srt(v) sort(all(v))         // sort

#define mxe(v) *max_element(all(v)) // find max element in vector

#define mne(v) *min_element(all(v)) // find min element in vector

#define rev(v) reverse(all(v))

#define sum_arr(v) accumulate(all(v), 0LL)

#define pq_max priority_queue<int>

#define pq_min priority_queue<int, vector<int>, greater<int>>

#define yes cout << "YES" << "\n"

#define no cout << "NO" << "\n"

// function

ll gcd(ll a, ll b)

{

    if (a == 0)

        return b;

    return gcd(b % a, a);

}

ll ncr(ll n, ll r)

{

    ll res = 1;

    fr(i, 0, r)

    {

        res = res * (n - i);

        res = res / (i + 1);

    }

    return res;

}

int lcm(int a, int b)

{

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

}

vector<int> simpleSieve(int limit)

{

    vector<bool> is_prime(limit + 1, true);

    vector<int> primes;

    for (int p = 2; p <= limit; ++p)

    {

        if (is_prime[p])

        {

            primes.push_back(p);

            for (int multiple = p * p; multiple <= limit; multiple += p)

            {

                is_prime[multiple] = false;

            }

        }

    }

    return primes;

}

int primeinrange(int L, int R)

{

    int limit = sqrt(R);

    vector<int> primes = simpleSieve(limit);

    vector<bool> is_prime(R - L + 1, true);

    for (int prime : primes)

    {

        int start = max(prime * prime, (L + prime - 1) / prime * prime);

        for (int j = start; j <= R; j += prime)

        {

            is_prime[j - L] = false;

        }

    }

    if (L == 1)

        is_prime[0] = false;

    int c = 0;

    for (int i = 0; i <= R - L; ++i)

    {

        if (is_prime[i])

        {

            c++;

        }

    }

    return c;

}

int mod_exp(int base, int exp, int mod)

{

    int result = 1;

    while (exp > 0)

    {

        if (exp % 2 == 1)

        {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

// Code by harshsingh9222

int exp(int k,int c)

{

    return pow(k,c);

}

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

    vl a(n);

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

    {

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

    }

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

    {

        a[x]=2;

    }

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

    {

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

    }

    cout<<'\n';

}

signed main()

{

    ios_base ::sync_with_stdio(false);

    cin.tie(0);

    cout << setprecision(12) << fixed;

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

Answer: 1


#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 || (x+n-y) % 2) 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>

#include <algorithm>

#include <ctime>

using namespace std;

#define ull unsigned long long

#define cy cout << "YES\n"

#define cn cout << "NO\n"

#define new cout << endl

#define ll  long long

#define pb push_back

#define vll vector<long long>

#define INF (long long)1e9

#define MOD 1000000007

#define mp make_pair

#define F first

#define S second

#define f(i, a, b) for(long long i = a; i < b; i++) // Loop from a to b

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 * b) /gcd(a, b);

}

long long factorial(int n) {

    long long result = 1;

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

        result *= i;

    }

    return result;

}

long long combination(int n, int r) {

    if (r > n) return 0;

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

    if (r > n - r) r = n - r;

    long long result = 1;

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

        result *= (n - i);

        result /= (i + 1);

    }

    return result;

}

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

    if (floor(log2(a.first)) != floor(log2(b.first))) {

        return floor(log2(a.first)) <floor(log2(b.first));

    }

    else if(a.second!=b.second){

        return a.second<b.second;

    }

    return a.first > b.first;

};

vector<long long> sieve_of_eratosthenes(long long limit) {

    vector<bool> prime(limit + 1, true);

    prime[0] = prime[1] = false;

    for (long long num = 2; num * num <= limit; ++num) {

        if (prime[num]) {

            for (long long multiple = num * num; multiple <= limit; multiple += num) {

                prime[multiple] = false;

            }

        }

    }

    vector<long long> primes;

    for (long long i = 2; i <= limit; ++i) {

        if (prime[i]) {

            primes.push_back(i);

        }

    }

    return primes;

};

void merge(int arr[], int left, int right) {

    if (left >= right) return;

    int mid = left + (right - left) / 2;

    merge(arr, left, mid);

    merge(arr, mid + 1, right);

    int n1 = mid - left + 1;

    int n2 = right - mid;

    int L[n1], R[n2];

    for (int i = 0; i < n1; i++) L[i] = arr[left + i];

    for (int i = 0; i < n2; i++) R[i] = arr[mid + 1 + i];

    int i = 0, j = 0, k = left;

    while (i < n1 && j < n2) {

        if (L[i] <= R[j]) arr[k++] = L[i++];

        else arr[k++] = R[j++];

    }

    while (i < n1) arr[k++] = L[i++];

    while (j < n2) arr[k++] = R[j++];

};

void mergeSort(int arr[], int left, int right) {

    if (left < right) {

        int mid = left + (right - left) / 2;

        mergeSort(arr, left, mid);

        mergeSort(arr, mid + 1, right);

        merge(arr, left, right);

    }

};

struct item{

    ll m,c;

};

int count_trailing_zeros(ll n) {

    int count = 0;

    while ((n & 1) == 0 && n != 0) {

        count++;

        n >>= 1;

    }

    return count;

}

int popcount(ll n) {

    int count = 0;

    while (n) {

        n = n & (n - 1);

        count++;

    }

    return count;

}

struct segTree {

    ll size;

    vll sums;

    void init(int n) {

        size = 1;

        while (size < n) {

            size *= 2;

        }

        sums.assign(2 * size, 0LL);

    }

    void set(ll i, ll v, ll x, ll lx, ll rx) {

        if (rx - lx == 1) {

            sums[x] = v;

            return;

        }

        ll m = (lx + rx) / 2;

        if (i < m) {

            set(i, v, 2 * x + 1, lx, m);

        }

        else {

            set(i, v, 2 * x + 2, m, rx);

        }

        sums[x] = gcd(sums[2 * x + 1] , sums[2 * x + 2]);

    }

    void set(ll i, ll v) {

        set(i, v, 0, 0, size);

    }

    ll sum(ll l, ll r, ll x, ll lx, ll rx) {

        if (lx >= r || l >= rx) return 1e9;

        if (lx >= l && rx <= r) return sums[x];

        ll m = (lx + rx) / 2;

        ll s1 = sum(l, r, 2 * x + 1, lx, m);

        ll s2 = sum(l, r, 2 * x + 2, m, rx);

        return gcd(s1 , s2);

    }

    ll sum(ll l, ll r) {

        return sum(l, r, 0, 0, size);

    }

};

bool isPerfectPowerOf3(int n) {

    if (n <= 0) {

        return false;

    }

    while (n % 3 == 0) {

        n /= 3;

    }

    return n == 1;

}

int main() {

    #ifndef ONLINE_JUDGE

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

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

    #endif

    ll test_cases;

    cin>>test_cases;

    auto start = chrono::high_resolution_clock::now();

    f(j,0,test_cases){

        ll m,y,x,r1,maxi=0,k;bool change=true; bool sorted=false;ll sum=0;ll sum1=0;ll mini=1e9;

        long long n,d;

        cin>>n>>d>>k;

        vll vec_1(n);

        if(n%2==0){

            f(i,0,n){

                vec_1[i]=i%2;

            }

            if(vec_1[d-1]==vec_1[k-1]){

                if(d-1==0){

                    set<ll> i;

                    i.insert(vec_1[n-1]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

                else if(d-1!=n-1){

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

                else{

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[0]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

            }

        }

        else{

            f(i,0,n-1){

                vec_1[i]=i%2;

            }

            vec_1[n-1]=2;

            if(vec_1[d-1]==vec_1[k-1]){

                if(d-1==0){

                    set<ll> i;

                    i.insert(vec_1[n-1]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

                else{

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

            }

        }

        if(d!=n && k!=n){

            set<ll> t;

            t.insert(vec_1[n-2]);

            t.insert(vec_1[0]);

            f(z,0,4){

                if(t.find(z)==t.end()){

                    vec_1[n-1]=z;

                    break;

                }

            }

        }

        else if(d==n){

            set<ll> t;

            t.insert(vec_1[n-2]);

            t.insert(vec_1[0]);

            t.insert(vec_1[k-1]);

            f(z,0,4){

                if(t.find(z)==t.end()){

                    vec_1[n-1]=z;

                    break;

                }

            }

        }

        else{

            set<ll> t;

            t.insert(vec_1[n-2]);

            t.insert(vec_1[0]);

            t.insert(vec_1[d-1]);

            f(z,0,4){

                if(t.find(z)==t.end()){

                    vec_1[n-1]=z;

                    break;

                }

            }

        }

        if(d-1==0){

            set<ll> i;

            i.insert(vec_1[n-1]);

            i.insert(vec_1[d]);

            i.insert(vec_1[k-1]);

            f(z,0,4){

                if(i.find(z)==i.end()){

                    vec_1[d-1]=z;

                    break;

                }

            }

        }

        else{

            set<ll> i;

            i.insert(vec_1[d-2]);

            i.insert(vec_1[d]);

            i.insert(vec_1[k-1]);

            f(z,0,4){

                if(i.find(z)==i.end()){

                    vec_1[d-1]=z;

                    break;

                }

            }

        }

        f(i,0,n){

            cout<<vec_1[i]<<" ";

        }

        cout<<endl;

    }

    auto end = chrono::high_resolution_clock::now();

    chrono::duration<double> duration = end - start;

    //cout << "Time taken: " << duration.count() << " seconds" << endl;

    return 0;

}

#include<bits/stdc++.h>

#include <algorithm>

#include <ctime>

using namespace std;

#define ull unsigned long long

#define cy cout << "YES\n"

#define cn cout << "NO\n"

#define new cout << endl

#define ll  long long

#define pb push_back

#define vll vector<long long>

#define INF (long long)1e9

#define MOD 1000000007

#define mp make_pair

#define F first

#define S second

#define f(i, a, b) for(long long i = a; i < b; i++) // Loop from a to b

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 * b) /gcd(a, b);

}

long long factorial(int n) {

    long long result = 1;

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

        result *= i;

    }

    return result;

}

long long combination(int n, int r) {

    if (r > n) return 0;

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

    if (r > n - r) r = n - r;

    long long result = 1;

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

        result *= (n - i);

        result /= (i + 1);

    }

    return result;

}

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

    if (floor(log2(a.first)) != floor(log2(b.first))) {

        return floor(log2(a.first)) <floor(log2(b.first));

    }

    else if(a.second!=b.second){

        return a.second<b.second;

    }

    return a.first > b.first;

};

vector<long long> sieve_of_eratosthenes(long long limit) {

    vector<bool> prime(limit + 1, true);

    prime[0] = prime[1] = false;

    for (long long num = 2; num * num <= limit; ++num) {

        if (prime[num]) {

            for (long long multiple = num * num; multiple <= limit; multiple += num) {

                prime[multiple] = false;

            }

        }

    }

    vector<long long> primes;

    for (long long i = 2; i <= limit; ++i) {

        if (prime[i]) {

            primes.push_back(i);

        }

    }

    return primes;

};

void merge(int arr[], int left, int right) {

    if (left >= right) return;

    int mid = left + (right - left) / 2;

    merge(arr, left, mid);

    merge(arr, mid + 1, right);

    int n1 = mid - left + 1;

    int n2 = right - mid;

    int L[n1], R[n2];

    for (int i = 0; i < n1; i++) L[i] = arr[left + i];

    for (int i = 0; i < n2; i++) R[i] = arr[mid + 1 + i];

    int i = 0, j = 0, k = left;

    while (i < n1 && j < n2) {

        if (L[i] <= R[j]) arr[k++] = L[i++];

        else arr[k++] = R[j++];

    }

    while (i < n1) arr[k++] = L[i++];

    while (j < n2) arr[k++] = R[j++];

};

void mergeSort(int arr[], int left, int right) {

    if (left < right) {

        int mid = left + (right - left) / 2;

        mergeSort(arr, left, mid);

        mergeSort(arr, mid + 1, right);

        merge(arr, left, right);

    }

};

struct item{

    ll m,c;

};

int count_trailing_zeros(ll n) {

    int count = 0;

    while ((n & 1) == 0 && n != 0) {

        count++;

        n >>= 1;

    }

    return count;

}

int popcount(ll n) {

    int count = 0;

    while (n) {

        n = n & (n - 1);

        count++;

    }

    return count;

}

struct segTree {

    ll size;

    vll sums;

    void init(int n) {

        size = 1;

        while (size < n) {

            size *= 2;

        }

        sums.assign(2 * size, 0LL);

    }

    void set(ll i, ll v, ll x, ll lx, ll rx) {

        if (rx - lx == 1) {

            sums[x] = v;

            return;

        }

        ll m = (lx + rx) / 2;

        if (i < m) {

            set(i, v, 2 * x + 1, lx, m);

        }

        else {

            set(i, v, 2 * x + 2, m, rx);

        }

        sums[x] = gcd(sums[2 * x + 1] , sums[2 * x + 2]);

    }

    void set(ll i, ll v) {

        set(i, v, 0, 0, size);

    }

    ll sum(ll l, ll r, ll x, ll lx, ll rx) {

        if (lx >= r || l >= rx) return 1e9;

        if (lx >= l && rx <= r) return sums[x];

        ll m = (lx + rx) / 2;

        ll s1 = sum(l, r, 2 * x + 1, lx, m);

        ll s2 = sum(l, r, 2 * x + 2, m, rx);

        return gcd(s1 , s2);

    }

    ll sum(ll l, ll r) {

        return sum(l, r, 0, 0, size);

    }

};

bool isPerfectPowerOf3(int n) {

    if (n <= 0) {

        return false;

    }

    while (n % 3 == 0) {

        n /= 3;

    }

    return n == 1;

}

int main() {

    #ifndef ONLINE_JUDGE

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

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

    #endif

    ll test_cases;

    cin>>test_cases;

    auto start = chrono::high_resolution_clock::now();

    f(j,0,test_cases){

        ll m,y,x,r1,maxi=0,k;bool change=true; bool sorted=false;ll sum=0;ll sum1=0;ll mini=1e9;

        long long n,d;

        cin>>n>>d>>k;

        vll vec_1(n);

        if(n%2==0){

            f(i,0,n){

                vec_1[i]=i%2;

            }

            if(vec_1[d-1]==vec_1[k-1]){

                if(d-1==0){

                    set<ll> i;

                    i.insert(vec_1[n-1]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

                else if(d-1!=n-1){

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

                else{

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[0]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

            }

        }

        else{

            f(i,0,n-1){

                vec_1[i]=i%2;

            }

            vec_1[n-1]=2;

            if(vec_1[d-1]==vec_1[k-1]){

                if(d-1==0){

                    vec_1[d-1]=3;

                }

                else{

                    set<ll> i;

                    i.insert(vec_1[d-2]);

                    i.insert(vec_1[d]);

                    i.insert(vec_1[k-1]);

                    f(z,0,4){

                        if(i.find(z)==i.end()){

                            vec_1[d-1]=z;

                            break;

                        }

                    }

                }

            }

        }

        f(i,0,n){

            cout<<vec_1[i]<<" ";

        }

        cout<<endl;

    }

    auto end = chrono::high_resolution_clock::now();

    chrono::duration<double> duration = end - start;

    //cout << "Time taken: " << duration.count() << " seconds" << endl;

    return 0;

}

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> groups(n + 1);

        // Start with filling most positions with alternating 0s and 1s

        int curr_val = 0;

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

            if (i == y) {

                groups[i] = 2;

            } else {

                groups[i] = curr_val;

                curr_val = 1 - curr_val;

            }

        }

        // Then adjust values working backwards from y to ensure MEX property holds

        int curr = y;

        while (curr != x) {

            curr = (curr == 1) ? n : curr - 1;

            if (curr == x) break;

            // Get next value (considering circular array)

            int next = (curr == n) ? 1 : curr + 1;

            // If next is y, get the value after y

            if (next == y) {

                next = (next == n) ? 1 : next + 1;

            }

            // Adjust current position to maintain MEX property

            groups[curr] = (groups[next] + 1) % 2;

        }

        // Ensure x position has value 0

        groups[x] = 0;

        // Print result

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

            cout << groups[i] << " ";

        }

        cout << "\n";

    }

    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> groups(n);

        groups[x] = 0;

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

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

        }

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

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

        }

        if (groups[(y - 1) % n] == 1 || groups[(y+1) % n] == 1) groups[y] = 2;

        else{

            groups[y] = 1;

        }

        for (auto g : groups){

            cout << g << " ";

        }

        cout << '\n';

    }

}

Answer: 2


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#define FOR(i, x, n) for(int i = x; i < n; i++)

#define F0R(i, n) FOR(i, 0, n)

#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)

#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

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

#define F first

#define S second

#define PB push_back

#define EP emplace_back

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

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

using namespace std;

typedef long long LL;

typedef long double LD;

typedef pair<int, int> PII;

typedef pair<LL, LL> PLL;

typedef vector<int> VI;

typedef vector<LL> VLL;

typedef vector<PII> VPII;

typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 2e5 + 7;

const int INF = 1e9 + 7;

const int LOG = 22;

const int A = 26;

const int SQ = 320;

const int MOD = 1e9 + 7;

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

int n, x, y;

int ans[N];

void solve() {

    cin >> n >> x >> y;

    x--; y--;

    if (n & 1) {

        ans[x] = 2;

        FOR(i, x + 1, n) ans[i] = ((x - i) % 2 == 0 ? 1 : 0);

        R0F(i, x) ans[i] = ((x - i) % 2 == 0 ? 0 : 1);

    }

    else {

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

            F0R(i, n) ans[i] = (i & 1);

        }

        else {

            F0R(i, n) ans[i] = (abs(x - i) % 2 == 0 ? 0 : 1);

            ans[x] = 2;

        }

    }

    F0R(i, n) cout << ans[i] << ' ';

    cout << endl;

}

int main() {

    IOS;

    int t; cin >> t;

    while(t--) solve();

}

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#define FOR(i, x, n) for(int i = x; i < n; i++)

#define F0R(i, n) FOR(i, 0, n)

#define ROF(i, x, n) for(int i = n - 1; i >= x; i--)

#define R0F(i, n) ROF(i, 0, n)

#define WTF cout << "WTF" << endl

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

#define F first

#define S second

#define PB push_back

#define EP emplace_back

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

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

using namespace std;

typedef long long LL;

typedef long double LD;

typedef pair<int, int> PII;

typedef pair<LL, LL> PLL;

typedef vector<int> VI;

typedef vector<LL> VLL;

typedef vector<PII> VPII;

typedef vector<PLL> VPLL;

typedef complex<LD> Point;

const int N = 2e5 + 7;

const int INF = 1e9 + 7;

const int LOG = 22;

const int A = 26;

const int SQ = 320;

const int MOD = 1e9 + 7;

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

int n, x, y;

int ans[N];

void solve() {

    cin >> n >> x >> y;

    x--; y--;

    if (n & 1) {

        ans[x] = 2;

        FOR(i, x + 1, n) ans[i] = ((x - i) % 2 == 0 ? 1 : 0);

        R0F(i, x) ans[i] = ((x - i) % 2 == 0 ? 0 : 1);

    }

    else {

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

            F0R(i, n) ans[i] = (i & 1);

            ans[x] = 2;

        }

        else {

            F0R(i, n) ans[i] = (abs(x - i) % 2 == 0 ? 0 : 1);

        }

    }

    F0R(i, n) cout << ans[i] << ' ';

    cout << endl;

}

int main() {

    IOS;

    int t; cin >> t;

    while(t--) solve();

}

Answer: 2


#include <bits/stdc++.h>

int main() {

  for (int _ = (std::cin.tie(0), not std::ios::sync_with_stdio(0)); _ or std::cin >> _, _; _--) {

    int n, x, y;

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

    x--, y--;

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

    if (n % 2 == 1) {

      a[x] = 2;

      int digit = 0;

      for (int i = (x + 1) % n; i != x; (++i) %= n) a[i] = digit, digit = not digit;

    } else {

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

      if (a[x] == 1 and a[y] == 1) a[x] = 2;

      if (a[x] == 0 and a[y] == 0) a[x] = 2;

    }

    for (int val : a) std::cout << val << " ";

    std::cout << "\n";

  }

}

#include <bits/stdc++.h>

int main() {

  for (int _ = (std::cin.tie(0), not std::ios::sync_with_stdio(0)); _ or std::cin >> _, _; _--) {

    int n, x, y;

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

    x--, y--;

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

    if (n % 2 == 1) {

      a[x] = 2;

      int digit = 0;

      for (int i = (x + 1) % n; i != x; (++i) %= n) a[i] = digit, digit = not digit;

    } else {

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

      if (a[x] == 1 and a[y] == 1) a[x] = 2;

      if (a[x] == 0 and a[y] == 0) a[x] = 2;

    }

    DEBUG(a);

  }

}

Answer: 1


#include <bits/stdc++.h>

#define ll long long

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

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

#define int long long

#define inf LONG_MAX

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

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

#define vec vector<int>

#define no cout << "NO" << '\n';

#define yes cout << "YES" << '\n';

#define nl cout << '\n';

#define MOD 1000000007

#define fs fflush(stdout);

#define pb push_back

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

#define ump unordered_map<int, int>

#define vs vector<string>

#define vv vector<vector<int>>

#define vb vector<bool>

using namespace std;

void solve();

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

    return 0;

}

void solve() {

   int n,m,k;

   cin>>n>>m>>k;

   vec a(n,-1);

   a[m-1]=0;

   a[k-1]=1;

   m--,k--;

   for(int i=m+1;i<k-1;i++)

    a[i]=!a[i-1];

   a[k-1]=(a[k-2]==1?0:2);

   for(int i=k+1;;i++)

   {

       if(i%n==(m-1+n)%n)break;

       else if(a[i%n]==-1) a[i%n]=!a[(i-1+n)%n];

   }

   if(a[(m-1+n)%n]==-1)

   a[(m-1+n)%n] =(a[(m-2+n)%n]==0?1:2);

   loop(i,n) cout<<a[i]<<" ";nl

}

#include <bits/stdc++.h>

#define ll long long

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

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

#define int long long

#define inf LONG_MAX

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

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

#define vec vector<int>

#define no cout << "NO" << '\n';

#define yes cout << "YES" << '\n';

#define nl cout << '\n';

#define MOD 1000000007

#define fs fflush(stdout);

#define pb push_back

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

#define ump unordered_map<int, int>

#define vs vector<string>

#define vv vector<vector<int>>

#define vb vector<bool>

using namespace std;

void solve();

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

        solve();

    return 0;

}

void solve() {

   int n,m,k;

   cin>>n>>m>>k;

   vec a(n,-1);

   a[m-1]=0;

   a[k-1]=1;

   m--,k--;

   for(int i=m+1;i<k-1;i++)

    a[i]=!a[i-1];

   if(a[k-1]==-1)

   a[k-1]=(a[k-2]==1?0:2);

   for(int i=k+1;;i++)

   {

       if(i%n==(m-1+n)%n)break;

       else if(a[i%n]==-1) a[i%n]=!a[(i-1+n)%n];

   }

   if(a[(m-1+n)%n]==-1)

   a[(m-1+n)%n] =(a[(m-2+n)%n]==0?1:2);

   loop(i,n) cout<<a[i]<<" ";nl

}

Answer: 2


#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<queue>

#include<array>

#include<stack>

#include<set>

#include<map>

#include<vector>

#include<ctime>

#include<bitset>

#include<random>

#include<tuple>

#define ull unsigned long long

#define ll long long

#define max_ll 9223372036854775807

#define max_int 2147483647

#define elif else if

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

#define nep(i, r, l) for(register ll i = r; i >= l; --i)

#define YES puts("Yes");

#define NO puts("No");

using namespace std;

template<class T>inline void read(T &x)

{

    x=0;char c=getchar();bool f=0;

    while(!isdigit(c))f^=c=='-',c=getchar();

    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();

    if(f)x=-x;

}

template<class T>inline void print(T x)

{

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

    if(x>9)print(x/10);

    putchar('0'+x%10);

}

int t;

int n;

int x,y;

int ans[200005];

void sol(){

	read(n);read(x);read(y);

	ans[x]=0;

	ans[y]=1;

	int len=y-x-1;

	if(len%2==0){

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

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

		}

	}else{

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

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

		}

		ans[y-1]=2;

	}

	len=n-len-2;

	int k=1;

	if(len%2==0){

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

			ans[i]=k;

			k^=1;

		}

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

			ans[i]=k;

			k^=1;

		}

	}else{

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

			ans[i]=k;

			k^=1;

		}

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

			ans[i]=k;

			k^=1;

		}

		ans[y%n+1]=2;

	}

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

		printf("%d ",ans[i]);

	puts("");

}

int main(){

	read(t);

	while(t--){

		sol();

	}

	return 0;

}

#include<cstdio>

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<queue>

#include<array>

#include<stack>

#include<set>

#include<map>

#include<vector>

#include<ctime>

#include<bitset>

#include<random>

#include<tuple>

#define ull unsigned long long

#define ll long long

#define max_ll 9223372036854775807

#define max_int 2147483647

#define elif else if

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

#define nep(i, r, l) for(register ll i = r; i >= l; --i)

#define YES puts("Yes");

#define NO puts("No");

using namespace std;

template<class T>inline void read(T &x)

{

    x=0;char c=getchar();bool f=0;

    while(!isdigit(c))f^=c=='-',c=getchar();

    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();

    if(f)x=-x;

}

template<class T>inline void print(T x)

{

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

    if(x>9)print(x/10);

    putchar('0'+x%10);

}

int t;

int n;

int x,y;

int ans[200005];

void sol(){

	read(n);read(x);read(y);

	ans[x]=0;

	ans[y]=1;

	int len=y-x-1;

	if(len%2==0){

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

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

		}

	}else{

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

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

		}

		ans[y-1]=2;

	}

	len=n-len-2;

	int k=1;

	if(len%2==0){

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

			ans[i]=k;

			k^=1;

		}

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

			ans[i]=k;

			k^=1;

		}

	}else{

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

			ans[i]=k;

			k^=1;

		}

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

			ans[i]=k;

			k^=1;

		}

		ans[y+1]=2;

	}

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

		printf("%d ",ans[i]);

	puts("");

}

int main(){

	read(t);

	while(t--){

		sol();

	}

	return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

#define int long long

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

void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    x--;

    y--;

    vector<int> ans(n);

    loop(i, n, 1)

    {

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

    }

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

    {

        ans[x] = 2;

    }

    loop(i, n, 1)

    {

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

    }

    cout << endl;

}

int32_t main()

{

    ios::sync_with_stdio(false);

    cin.tie(0), cout.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;

#define int long long

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

void solve()

{

    int n, x, y;

    cin >> n >> x >> y;

    x--;

    y--;

    vector<int> ans(n);

    loop(i, n, 1)

    {

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

    }

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

    {

        ans[x] = 2;

    }

    loop(i, n, 1)

    {

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

    }

    cout << endl;

}

int32_t main()

{

    ios::sync_with_stdio(false);

    cin.tie(0), cout.tie(0);

    int t = 1;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

Answer: 1


#include <iostream>

#include <vector>

#include <algorithm>

#include <climits>

#include <queue>

using namespace std;

using ll = long long int;

int main()

{

    ll i, j, n, k, t, d, m, l, v, x, y;

    cin >> t;

    while (t--)

    {

        cin>>n>>x>>y;

        int arr[n+1];

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

            if(i%2==0){

                arr[i]=1;

            }else{

                arr[i]=0;

            }

        }if(n%2==0){

            arr[n]=1;

        }else{

            arr[n]=2;

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

            if(y==n-1){

                arr[x]=2;

            }else{

                arr[y]=2;

            }

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

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

        }cout<<endl;

    }

    return 0;

}

#include <iostream>

#include <vector>

#include <algorithm>

#include <climits>

#include <queue>

using namespace std;

using ll = long long int;

int main()

{

    ll i, j, n, k, t, d, m, l, v, x, y;

    cin >> t;

    while (t--)

    {

        cin >> n >> x >> y;

        int arr[n + 1];

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

        {

            if (i % 2 == 0)

            {

                arr[i] = 1;

            }

            else

            {

                arr[i] = 0;

            }

        }

        if (n % 2 == 0)

        {

            arr[n] = 1;

        }

        else

        {

            arr[n] = 2;

        }

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

        {

            if (y == n - 1)

            {

                arr[x] = 2;

            }

            else

            {

                arr[y] = 2;

                if (y != n && arr[y + 2] == 2)

                {

                    arr[y + 1] = 0;

                    arr[n] = 1;

                }

            }

        }

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

        {

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

        }

        cout << endl;

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

void solve(int n, int x, int y) {

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

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

        int prev = (i - 1 + n) % n;

        int next = (i + 1) % n;

        adj[i].push_back(prev);

        adj[i].push_back(next);

    }

    auto is_adjacent = [&](int u, int v) -> bool {

        return (u == v - 1) || (u == v + 1) || (u == 1 && v == n) || (u == n && v == 1);

    };

    if (!is_adjacent(x, y)) {

        adj[x].push_back(y);

        adj[y].push_back(x);

    }

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

    queue<int> q;

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

        q.push(i);

    }

    vector<bool> in_queue(n + 1, true);

    while (!q.empty()) {

        int u = q.front();

        q.pop();

        in_queue[u] = false;

        int mask = 0;

        for (const auto &v : adj[u]) {

            if (labels[v] < 32) {

                mask |= (1 << labels[v]);

            }

        }

        int mex = 0;

        while (mask & (1 << mex)) {

            ++mex;

        }

        if (labels[u] != mex) {

            labels[u] = mex;

            for (const auto &v : adj[u]) {

                if (!in_queue[v]) {

                    q.push(v);

                    in_queue[v] = true;

                }

            }

        }

    }

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

        cout << labels[i] << " ";

    }

    cout << "\n";

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        int n, x, y;

        cin >> n >> x >> y;

        solve(n, x, y);

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

void solve(int n, int x, int y) {

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

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

        int prev = i - 1;

        if (prev == 0) {

            prev = n;

        }

        int next = i + 1;

        if (next > n) {

            next = 1;

        }

        adj[i].push_back(prev);

        adj[i].push_back(next);

    }

    auto is_adjacent = [&](int u, int v) -> bool {

        return (u == v - 1) || (u == v + 1) || (u == 1 && v == n) || (u == n && v == 1);

    };

    if (!is_adjacent(x, y)) {

        adj[x].push_back(y);

        adj[y].push_back(x);

    }

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

    queue<int> q;

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

        q.push(i);

    }

    vector<bool> in_queue_flag(n + 1, true);

    while (!q.empty()) {

        int u = q.front();

        q.pop();

        in_queue_flag[u] = false;

        int mask = 0;

        for (auto &v : adj[u]) {

            if (labels[v] < 32) {

                mask |= (1 << labels[v]);

            }

        }

        int mex = 0;

        while (mask & (1 << mex)) {

            ++mex;

        }

        if (labels[u] != mex) {

            labels[u] = mex;

            for (auto &v : adj[u]) {

                if (!in_queue_flag[v]) {

                    q.push(v);

                    in_queue_flag[v] = true;

                }

            }

        }

    }

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

        cout << labels[i] << (i < n ? " " : "\n");

    }

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        int n, x, y;

        cin >> n >> x >> y;

        solve(n, x, y);

    }

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define int long long int

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

#define no cout << "NO\n"

#define yes cout << "YES\n"

#define mod 1000000007

#define endd cout << "\n"

#define endl "\n"

#define came cout<<"came\n";

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x <<" "; __print(x); cerr << endl;

#define start_T auto start = std::chrono::high_resolution_clock::now();

#define end_T auto end = std::chrono::high_resolution_clock::now(); \

chrono::duration<double> duration = end - start; \

cout << "Time taken: "<<duration.count()<<" seconds"<<endl;

#else

#define debug(x)

#define start_T

#define end_T

#endif

//----------------------------------------------------------------------------------------------

template<class T>

void __print(T t){cerr<<t<<" ";}

template<class T>

void in(T a[],int n){for(int i=0;i<n;i++) cin>>a[i];}

template<class T>

void out(T a[], int x){for(int i = 0; i < x; i++){cout << a[i] << " "; } cout << endl;}

template<class T>

void in(vector<T>& a, int n){for(int i = 0; i < n; i++){ T x; cin >> x; a.push_back(x);}}

template<class T>

void in(vector<vector<T>>& a,int n,int m){vector<T> tp;for(int i=0;i<n;i++){tp.clear();in(tp,m);a.push_back(tp);}}

template<class T>

void out(vector<T> a){for(auto i : a)cout << i << " ";cout << endl;}

struct pair_hash{

template <class T1, class T2>

std::size_t operator()(const pair<T1, T2>& pair) const {return std::hash<T1>()(pair.first) ^ (std::hash<T2>()(pair.second) << 1);}};

class DSU{

 public:

    vector<int> parent,rank,size;

    DSU(int n){

         // rank.resize(n+1,0);

         parent.resize(n+1);

         size.resize(n+1,1);

         iota(parent.begin(),parent.end(),0);

    }

    //finding ultimate parent()

    int fup(int node){

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

         // path compression

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

    }

    // union by rank()

    void joinr(int u,int v){

         int p1 = fup(u), p2 = fup(v);

         if(p1==p2) return;

         else if(rank[p1]>rank[p2]){

             parent[p2]=p1;

         }

         else if(rank[p2]>rank[p1]){

             parent[p1]=p2;

         }

         else{

            parent[p1]=p2;

            //we ar attaching component p1 to p2

            rank[p2]++;

         }

    }

    // union by size()

    void joins(int u,int v){

        int p1 = fup(u);

        int p2 = fup(v);

        if(p1==p2) return;

        else if(size[p1]>size[p2]) size[p1]+=size[p2],parent[p2]=p1;

        else size[p2]+=size[p1],parent[p1]=p2;

}};

class SEG{

 public:

    vector<int> seg;

    vector<int> arr;

    vector<int> lazy;

    SEG(int n){

       this->seg = vector<int>(n*4+1,0);

       this->lazy = vector<int>(n*4+1,0);

       this->arr.clear();

    }

    void build(){

        if(this->arr.size()==0) return;

       this->build(0,0,this->arr.size()-1);

    }

    int query(int l,int r){

         return this->query(0,0,arr.size()-1,l,r);

    }

    // Builds a Seg Tree

    int build(int ind,int lo,int hi){

         if(lo==hi){

             return this->seg[ind] = this->arr[lo];

         }

         int mid = (lo+hi)/2;

         return this->seg[ind] = __gcd(build(2*ind+1,lo,mid),build(2*ind+2,mid+1,hi));

    }

    int query(int ind,int lo,int hi,int l,int r){

         //complete lying

         // l --- low -- high --- r

         if(lo>=l && hi<=r) return this->seg[ind];

         //Not overlap

         // lo -- hi -- l -- r [or] l -- r -- lo -- hi

         if(hi<l || lo>r) return 0;

         //Semi Overlap

         int mid = (lo+hi)/2;

         return __gcd(query(ind*2+1,lo,mid,l,r),query(ind*2+2,mid+1,hi,l,r));

    }

    // Updates the I'th ind value

    void update(int segind,int lo,int hi,int val,int ind){

         if(lo==hi && lo==ind){

             this->seg[segind] = val;

             return;

         }

         int mid = (lo+hi)/2;

         if(lo<=ind&&mid>=ind) update(2*segind+1,lo,mid,val,ind);

         else update(2*segind+2,mid+1,hi,val,ind);

         this->seg[segind] = max(this->seg[segind*2+1],this->seg[segind*2+2]);

    }

    //update Lazy

    void updatel(int ind,int lo,int hi,int l,int r,int val){

        // updating the pendings

        if(this->lazy[ind]!=0){

             this->seg[ind] = (hi-lo+1)*this->lazy[ind];

             if(hi!=lo){

                this->lazy[2*ind+1]=this->lazy[2*ind+2]=this->lazy[ind];

             }

             this->lazy[ind]=0;

        }

        if(lo>r || hi<l || lo>hi) return;

        // l -- lo -- hi -- r

        if(lo>=l && hi<=r){

             this->seg[ind] += (hi-lo+1) * val;

             if(lo!=hi){

                 this->lazy[2*ind+1]+= val;

                 this->lazy[2*ind+2]+= val;

             }

        }

        int mid = (lo+hi)/2;

        updatel(ind*2+1,lo,mid,l,r,val);

        updatel(ind*2+2,mid+1,hi,l,r,val);

        this->seg[ind] = this->seg[ind*2+1] + this->seg[ind*2+2];

    }

    int queryl(int ind,int lo,int hi,int l,int r){

        // updating the pendings

        if(this->lazy[ind]!=0){

             this->seg[ind] = (hi-lo+1)*this->lazy[ind];

             if(hi!=lo){

                this->lazy[2*ind+1]=this->lazy[2*ind+2]=this->lazy[ind];

             }

             this->lazy[ind]=0;

        }

        if(lo>r || hi<l || lo>hi) return 0;

        // l -- lo -- hi -- r

        if(lo>=l && hi<=r){

             return this->seg[ind];

        }

        int mid = (lo+hi)/2;

        return queryl(ind*2+1,lo,mid,l,r)+queryl(ind*2+2,mid+1,hi,l,r);

    }};

inline int fib(int n) {const double phi = (1 + sqrt(5)) / 2;const double psi = (1 - sqrt(5)) / 2;return round((pow(phi, n) - pow(psi, n)) / sqrt(5));}

inline int gcd(int A, int B){while(A>0&&B>0){if(A>B) A%=B;else B%=A;}return ((A==0)?B:A);}

inline int lcm(int A, int B) {return ((A * B) / (gcd(A, B)));}

inline bool isprime(int X) {if(X==1) return 0;if (X == 2) return true;for (int i = 2; i <= sqrt(X); i++) {if ((X % i) == 0)return false;}return true;}

// int Mod(string &a,int k){int rem=0;for(int i=0;i<a.size();i++){rem = (rem*10+(a[i]-'0'))%k;}return rem;}

class sieve{

  public:

  int n;

  vector<bool> is_prime;

  vector<int> primes;

  sieve(int n){

     this->n=n;

     is_prime.resize(n+1,true);

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

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

     if(is_prime[i]){

        primes.push_back(i);

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

            is_prime[j] = false;

    }

   }

  }

  bool fun(int ind){

     return is_prime[ind];

  } };

int pow(int a,int b){if(b==0) return 1;int res=pow(a,b/2);if(b%2) return ((((res*res)%mod)*a)%mod);else return ((res*res)%mod);}

int modInverse(int a,int p){int res=1,exp=p-2;while(exp){if(exp%2)res=(1LL*res*a)%p;a=(1LL*a*a)%p; exp/=2;}return res;}

//-------------------------------------------------UDF------------------------------------------------

signed main(){

  init;start_T;

  #ifndef ONLINE_JUDGE

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

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

  freopen("error.txt", "w", stderr);

  #endif

  ll _=1;

  cin>>_;

  while(_--){

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

     int a[n];

     memset(a,-1,sizeof(a));

     bool f=0;

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

          if(n%2) cout<<"0 1 2 ";

          bool f=0;

          for(int i=(n&1)?3:0;i<n;i++){

            cout<<f<<' ';

            f=!f;

          }

          endd;

     }

     else{

        int t = min(x,y)-1;

        y = max(x,y)-1,x = t;

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

        int tp = y-x+1;

        if(tp&1) a[y-1]=2;

        bool f=1;

        cerr<<tp<<endl;

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

           a[i] = f;

           f=!f;

        }

        tp=n-tp+2;

        debug(tp);

         if(tp&1){a[(y+1)%n]=2;

         f=0;

         for(int i=(y+2)%n;a[(i%n)]==-1;i++){

           a[(i%n)]=f;

           f=!f;

         }

        }

        else{

            f=0;

            for(int i=(y+1)%n;a[i%n]==-1;i++){

               a[i%n]=f;

               f=!f;

            }

        }

        out(a,n);

     }

  }

  end_T;

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define int long long int

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

#define no cout << "NO\n"

#define yes cout << "YES\n"

#define mod 1000000007

#define endd cout << "\n"

#define endl "\n"

#define came cout<<"came\n";

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x <<" "; __print(x); cerr << endl;

#define start_T auto start = std::chrono::high_resolution_clock::now();

#define end_T auto end = std::chrono::high_resolution_clock::now(); \

chrono::duration<double> duration = end - start; \

cout << "Time taken: "<<duration.count()<<" seconds"<<endl;

#else

#define debug(x)

#define start_T

#define end_T

#endif

//----------------------------------------------------------------------------------------------

template<class T>

void __print(T t){cerr<<t<<" ";}

template<class T>

void in(T a[],int n){for(int i=0;i<n;i++) cin>>a[i];}

template<class T>

void out(T a[], int x){for(int i = 0; i < x; i++){cout << a[i] << " "; } cout << endl;}

template<class T>

void in(vector<T>& a, int n){for(int i = 0; i < n; i++){ T x; cin >> x; a.push_back(x);}}

template<class T>

void in(vector<vector<T>>& a,int n,int m){vector<T> tp;for(int i=0;i<n;i++){tp.clear();in(tp,m);a.push_back(tp);}}

template<class T>

void out(vector<T> a){for(auto i : a)cout << i << " ";cout << endl;}

struct pair_hash{

template <class T1, class T2>

std::size_t operator()(const pair<T1, T2>& pair) const {return std::hash<T1>()(pair.first) ^ (std::hash<T2>()(pair.second) << 1);}};

class DSU{

 public:

    vector<int> parent,rank,size;

    DSU(int n){

         // rank.resize(n+1,0);

         parent.resize(n+1);

         size.resize(n+1,1);

         iota(parent.begin(),parent.end(),0);

    }

    //finding ultimate parent()

    int fup(int node){

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

         // path compression

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

    }

    // union by rank()

    void joinr(int u,int v){

         int p1 = fup(u), p2 = fup(v);

         if(p1==p2) return;

         else if(rank[p1]>rank[p2]){

             parent[p2]=p1;

         }

         else if(rank[p2]>rank[p1]){

             parent[p1]=p2;

         }

         else{

            parent[p1]=p2;

            //we ar attaching component p1 to p2

            rank[p2]++;

         }

    }

    // union by size()

    void joins(int u,int v){

        int p1 = fup(u);

        int p2 = fup(v);

        if(p1==p2) return;

        else if(size[p1]>size[p2]) size[p1]+=size[p2],parent[p2]=p1;

        else size[p2]+=size[p1],parent[p1]=p2;

}};

class SEG{

 public:

    vector<int> seg;

    vector<int> arr;

    vector<int> lazy;

    SEG(int n){

       this->seg = vector<int>(n*4+1,0);

       this->lazy = vector<int>(n*4+1,0);

       this->arr.clear();

    }

    void build(){

        if(this->arr.size()==0) return;

       this->build(0,0,this->arr.size()-1);

    }

    int query(int l,int r){

         return this->query(0,0,arr.size()-1,l,r);

    }

    // Builds a Seg Tree

    int build(int ind,int lo,int hi){

         if(lo==hi){

             return this->seg[ind] = this->arr[lo];

         }

         int mid = (lo+hi)/2;

         return this->seg[ind] = __gcd(build(2*ind+1,lo,mid),build(2*ind+2,mid+1,hi));

    }

    int query(int ind,int lo,int hi,int l,int r){

         //complete lying

         // l --- low -- high --- r

         if(lo>=l && hi<=r) return this->seg[ind];

         //Not overlap

         // lo -- hi -- l -- r [or] l -- r -- lo -- hi

         if(hi<l || lo>r) return 0;

         //Semi Overlap

         int mid = (lo+hi)/2;

         return __gcd(query(ind*2+1,lo,mid,l,r),query(ind*2+2,mid+1,hi,l,r));

    }

    // Updates the I'th ind value

    void update(int segind,int lo,int hi,int val,int ind){

         if(lo==hi && lo==ind){

             this->seg[segind] = val;

             return;

         }

         int mid = (lo+hi)/2;

         if(lo<=ind&&mid>=ind) update(2*segind+1,lo,mid,val,ind);

         else update(2*segind+2,mid+1,hi,val,ind);

         this->seg[segind] = max(this->seg[segind*2+1],this->seg[segind*2+2]);

    }

    //update Lazy

    void updatel(int ind,int lo,int hi,int l,int r,int val){

        // updating the pendings

        if(this->lazy[ind]!=0){

             this->seg[ind] = (hi-lo+1)*this->lazy[ind];

             if(hi!=lo){

                this->lazy[2*ind+1]=this->lazy[2*ind+2]=this->lazy[ind];

             }

             this->lazy[ind]=0;

        }

        if(lo>r || hi<l || lo>hi) return;

        // l -- lo -- hi -- r

        if(lo>=l && hi<=r){

             this->seg[ind] += (hi-lo+1) * val;

             if(lo!=hi){

                 this->lazy[2*ind+1]+= val;

                 this->lazy[2*ind+2]+= val;

             }

        }

        int mid = (lo+hi)/2;

        updatel(ind*2+1,lo,mid,l,r,val);

        updatel(ind*2+2,mid+1,hi,l,r,val);

        this->seg[ind] = this->seg[ind*2+1] + this->seg[ind*2+2];

    }

    int queryl(int ind,int lo,int hi,int l,int r){

        // updating the pendings

        if(this->lazy[ind]!=0){

             this->seg[ind] = (hi-lo+1)*this->lazy[ind];

             if(hi!=lo){

                this->lazy[2*ind+1]=this->lazy[2*ind+2]=this->lazy[ind];

             }

             this->lazy[ind]=0;

        }

        if(lo>r || hi<l || lo>hi) return 0;

        // l -- lo -- hi -- r

        if(lo>=l && hi<=r){

             return this->seg[ind];

        }

        int mid = (lo+hi)/2;

        return queryl(ind*2+1,lo,mid,l,r)+queryl(ind*2+2,mid+1,hi,l,r);

    }};

inline int fib(int n) {const double phi = (1 + sqrt(5)) / 2;const double psi = (1 - sqrt(5)) / 2;return round((pow(phi, n) - pow(psi, n)) / sqrt(5));}

inline int gcd(int A, int B){while(A>0&&B>0){if(A>B) A%=B;else B%=A;}return ((A==0)?B:A);}

inline int lcm(int A, int B) {return ((A * B) / (gcd(A, B)));}

inline bool isprime(int X) {if(X==1) return 0;if (X == 2) return true;for (int i = 2; i <= sqrt(X); i++) {if ((X % i) == 0)return false;}return true;}

// int Mod(string &a,int k){int rem=0;for(int i=0;i<a.size();i++){rem = (rem*10+(a[i]-'0'))%k;}return rem;}

class sieve{

  public:

  int n;

  vector<bool> is_prime;

  vector<int> primes;

  sieve(int n){

     this->n=n;

     is_prime.resize(n+1,true);

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

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

     if(is_prime[i]){

        primes.push_back(i);

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

            is_prime[j] = false;

    }

   }

  }

  bool fun(int ind){

     return is_prime[ind];

  } };

int pow(int a,int b){if(b==0) return 1;int res=pow(a,b/2);if(b%2) return ((((res*res)%mod)*a)%mod);else return ((res*res)%mod);}

int modInverse(int a,int p){int res=1,exp=p-2;while(exp){if(exp%2)res=(1LL*res*a)%p;a=(1LL*a*a)%p; exp/=2;}return res;}

//-------------------------------------------------UDF------------------------------------------------

signed main(){

  init;start_T;

  #ifndef ONLINE_JUDGE

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

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

  freopen("error.txt", "w", stderr);

  #endif

  ll _=1;

  cin>>_;

  while(_--){

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

     int a[n];

     memset(a,-1,sizeof(a));

     bool f=0;

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

          if(n%2) cout<<"0 1 2 ";

          bool f=0;

          for(int i=(n&1)?3:0;i<n;i++){

            cout<<f<<' ';

            f=!f;

          }

          endd;

     }

     else{

        int t = min(x,y)-1;

        y = max(x,y)-1,x = t;

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

        int tp = y-x+1;

        if(tp&1) a[y-1]=2;

        bool f=1;

        // cerr<<tp<<endl;

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

           a[i] = f;

           f=!f;

        }

        tp=n-tp+2;

        // debug(tp);

         if(tp&1) a[(y+1)%n]=2;

         else a[(y+1)%n]=0;

         f=1;

         for(int i=(y+2)%n;a[(i%n)]==-1;i++){

           a[(i%n)]=f;

           f=!f;

         }

        out(a,n);

     }

  }

  end_T;

}

Answer: 1


#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

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

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

#define BE(a) ((a).begin()),((a).end())

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair

int n, x, y;

int a[200005];

void Solve()

{

    int i;

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

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

    if ((x + 1) % n == y || (y + 1) % n == x) return;

    if (n % 2)

    {

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

        a[x] = 2;

    }

    else a[x] = 2;

}

void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}

void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

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

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}

#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

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

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

#define BE(a) ((a).begin()),((a).end())

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair

int n, x, y;

int a[200005];

void Solve()

{

    int i, j;

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

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

    if ((x + 1) % n != y && (y + 1) % n != x && a[x] == a[y])

    {

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

        a[x] = 2;

    }

    /*FOR(i, n)

    {

        set<int> b;

        for (j = -1; j <= 1; j++) b.insert(a[(n + i + j) % n]);

        if (i == x) b.insert(a[y]);

        else if (i == y) b.insert(a[x]);

        for (j = 0; ; j++) if (!b.count(j)) break;

        if (a[i] != j)

        {

            ;

        }

    }*/

}

void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}

void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

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

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

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--; vector<int> a(n);

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

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

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

		cout<<endl;

	}

	return 0;

}

#include<bits/stdc++.h>

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; int a[n+1];

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

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

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

		cout<<endl;

	}

	return 0;

}

Answer: 1