import static java.lang.Math.max;

import static java.lang.Math.min;

import static java.lang.Math.abs;

import java.util.*;

import java.io.*;

import java.math.*;

public final class Main {

    static PrintWriter out = new PrintWriter(System.out);

    static FastReader in = new FastReader();

    static final int MOD1 = (int) (1e9 + 7);

    static final int MOD2 = 998244353;

    static final int inf = Integer.MAX_VALUE;

    static final int minf = Integer.MIN_VALUE;

    static final long linf = 1L << 62;

    public static void main(String[] args){

        int tt = i();

        while (tt-- > 0) {

            solve();

        }

        out.flush();

    }

    public static void solve(){

        // int MIN = -1*(int) 1e9;

        // int MAX = (int) 1e9;

        // PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());

        int n = i();

        int x = i();

        int y = i();

        // String s = s();

        // int ar[]=input(n);

        int ar[]=new int[n];

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

            ar[i]=i&1;

        }

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

            ar[0]=2;

        }

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

            ar[y-1]=2;

        }

        pl(ar);

    }

    static int BinarySearch(long ar[], int k) {

        int lo = 0;

        int hi = ar.length - 1;

        int mid;

        int ans = -1;

        while (lo <= hi) {

            mid = lo + ((hi - lo) / 2);

            if (ar[mid] >= k) {

                ans = mid;

                hi = mid - 1;

            } else {

                lo = mid + 1;

            }

        }

        return ans;

    }

    // ------------------------------------------COMMON|FUNCTIONS--------------------------------------------------//

    // -------------BINARYSEARCH-----------//

    // UPPERBOUND find lowest i which satisfy a[i]>=x

    static int upperbound(List<Integer> a, int x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a.get(m) >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(List<Long> a, long x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a.get(m) >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(int[] a, int x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a[m] >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(long[] a, long x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a[m] >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    // LOWERBOUND find highest i which satisfy a[i]<=x

    static int lowerbound(List<Long> a, long x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a.get(m) <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(List<Integer> a, int x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a.get(m) <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(int[] a, int x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a[m] <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(long[] a, long x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a[m] <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    // -------------BINARYSEARCH-----------//

    // ---------------MATH-----------------//

    public static long fact(int n, int mod) {

        long res = 1;

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

            res = (res * i) % mod;

        }

        return res;

    }

    static int GCD(int a, int b) {

        int dividend = a > b ? a : b;

        int divisor = a < b ? a : b;

        while (divisor > 0) {

            int reminder = dividend % divisor;

            dividend = divisor;

            divisor = reminder;

        }

        return dividend;

    }

    static long GCD(long a, long b) {

        long dividend = a > b ? a : b;

        long divisor = a < b ? a : b;

        while (divisor > 0) {

            long reminder = dividend % divisor;

            dividend = divisor;

            divisor = reminder;

        }

        return dividend;

    }

    static long LCM(int a, int b) {

        return (long) a / GCD(a, b) * b;

    }

    static long LCM(long a, long b) {

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

    }

    static long pow(long a, long b, int mod) {

        long pow = 1;

        long x = a;

        while (b != 0) {

            if ((b & 1) != 0) {

                pow = (pow * x) % mod;

            }

            x = (x * x) % mod;

            b /= 2;

        }

        return pow;

    }

    static long pow(long a, long b) {

        long pow = 1;

        long x = a;

        while (b != 0) {

            if ((b & 1) != 0) {

                pow *= x;

            }

            x = x * x;

            b /= 2;

        }

        return pow;

    }

    static long modInverse(long x, int mod) {

        return pow(x, mod - 2, mod);

    }

    static boolean isPrime(long N) {

        if (N <= 1) {

            return false;

        }

        if (N <= 3) {

            return true;

        }

        if (N % 2 == 0 || N % 3 == 0) {

            return false;

        }

        for (int i = 5; i * i <= N; i = i + 6) {

            if (N % i == 0 || N % (i + 2) == 0) {

                return false;

            }

        }

        return true;

    }

    static long log(long a) {

        return (long) (Math.log(a));

    }

    static long log2(long a) {

        return (long) (Math.log(a) / Math.log(2));

    }

    static long sqrt(long x) {

        long start = 0, end = (long) 3e9, ans = 1;

        while (start <= end) {

            long mid = (start + end) / 2;

            if (mid * mid <= x) {

                ans = mid;

                start = mid + 1;

            } else

                end = mid - 1;

        }

        return ans;

    }

    static long ceil(long a, long b) {

        return (a / b) + ((a % b == 0) ? 0 : 1);

    }

    static boolean isPerfectSquare(double number) {

        double sqrt = Math.sqrt(number);

        return ((sqrt - Math.floor(sqrt)) == 0);

    }

    // ---------------MATH-----------------//

    // ---------------CALCS-----------------//

    static long sum(List<Long> a) {

        long sum = 0;

        for (long ele : a)

            sum += ele;

        return sum;

    }

    static long sum(int[] a) {

        long sum = 0;

        for (int ele : a)

            sum += ele;

        return sum;

    }

    static long sum(long[] a) {

        long sum = 0;

        for (long ele : a)

            sum += ele;

        return sum;

    }

    static int maxArray(long a[]) {

        int in = 0;

        long m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] > m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int maxArray(int a[]) {

        int in = 0;

        int m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] > m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int minArray(long a[]) {

        int in = 0;

        long m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] < m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int minArray(int a[]) {

        int in = 0;

        int m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] < m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    // ---------------CALCS-----------------//

    // ------------------------------------------COMMON|FUNCTIONS--------------------------------------------------//

    // ------------------------------------------MODIFICATIONS--------------------------------------------------//

    static void shuffle(int[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            int temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

    }

    static void shuffleAndSort(int[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            int temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

        Arrays.sort(arr);

    }

    static void shuffleAndSort(long[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            long temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

        Arrays.sort(arr);

    }

    static void swap(int A[], int a, int b) {

        int t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    static void swap(long A[], int a, int b) {

        long t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    static void swap(char A[], int a, int b) {

        char t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    public static String reverse(String str) {

        if (str == null) {

            return null;

        }

        return new StringBuilder(str).reverse().toString();

    }

    public static void reverse(int[] arr) {

        int l = 0;

        int r = arr.length - 1;

        while (l < r) {

            swap(arr, l, r);

            l++;

            r--;

        }

    }

    public static void reverse(long[] arr) {

        int l = 0;

        int r = arr.length - 1;

        while (l < r) {

            swap(arr, l, r);

            l++;

            r--;

        }

    }

    public static String repeat(char ch, int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

        for (int i = repeat - 1; i >= 0; i--) {

            buf[i] = ch;

        }

        return new String(buf);

    }

    public static String repeat(char ch[], int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

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

            buf[i] = ch[i % ch.length];

        }

        return new String(buf);

    }

    public static String repeat(String ch, int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

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

            buf[i] = ch.charAt(i % ch.length());

        }

        return new String(buf);

    }

    static void fillFrequency(Map<Long, Integer> map, long a[]) {

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

            fill(map, a[i]);

        }

    }

    static void fill(Map<Long, Integer> map, long val) {

        if (map.containsKey(val))

            map.put(val, map.get(val) + 1);

        else

            map.put(val, 1);

    }

    static void fillFrequency(Map<Integer, Integer> map, int a[]) {

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

            fill(map, a[i]);

        }

    }

    static void fill(Map<Integer, Integer> map, int val) {

        if (map.containsKey(val))

            map.put(val, map.get(val) + 1);

        else

            map.put(val, 1);

    }

    static void remove(Map<Long, Integer> map, long val) {

        if (map.get(val) == 1)

            map.remove(val);

        else

            map.replace(val, map.get(val) - 1);

    }

    static void remove(Map<Integer, Integer> map, int val) {

        if (map.get(val) == 1)

            map.remove(val);

        else

            map.replace(val, map.get(val) - 1);

    }

    // ------------------------------------------MODIFICATIONS--------------------------------------------------//    // -----------------------------------------------PRECOMPUTE--------------------------------------------------//

    // --------------BITS-----------------//

    static int[][] PrefixBitsCount(int n, int[] a) {

        int pref[][] = new int[n + 1][32];

        // Builds the prefix sums for each bit

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

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

                if ((a[i] & (1 << j)) != 0) {

                    pref[i + 1][j] = pref[i][j] + 1;

                } else {

                    pref[i + 1][j] = pref[i][j];

                }

            }

        }

        return pref;

    }

    static int[] prefixAnd(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] & a[i];

        }

        return pre;

    }

    static int[] prefixOr(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] | a[i];

        }

        return pre;

    }

    static int[] prefixXor(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] ^ a[i];

        }

        return pre;

    }

    // --------------BITS-----------------//

    // --------------ARRAYS-----------------//

    static int[] getPrefMax(int arr[]) {

        int n = arr.length;

        int pref[] = new int[n];

        pref[0] = arr[0];

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

            pref[i] = max(arr[i], pref[i - 1]);

        }

        return pref;

    }

    static int[] getPrefMin(int arr[]) {

        int n = arr.length;

        int pref[] = new int[n];

        pref[0] = arr[0];

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

            pref[i] = min(arr[i], pref[i - 1]);

        }

        return pref;

    }

    static int[] getSuffMin(int arr[]) {

        int n = arr.length;

        int suff[] = new int[n];

        suff[n - 1] = arr[n - 1];

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

            suff[i] = min(suff[i + 1], arr[i]);

        }

        return suff;

    }

    static long[] prefix(int[] a) {

        long[] pre = new long[a.length + 1];

        pre[0] = 0;

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

            pre[i + 1] = pre[i] + a[i];

        }

        return pre;

    }

    static List<Long> prefix(List<Integer> a) {

        List<Long> pre = new ArrayList<>();

        pre.add(0l);

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

            pre.add(pre.get(i) + a.get(i));

        }

        return pre;

    }

    static long[] prefix(long[] a) {

        long[] pre = new long[a.length + 1];

        pre[0] = 0;

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

            pre[i + 1] = pre[i] + a[i];

        }

        return pre;

    }

    static long[] suffix(int[] a) {

        long[] post = new long[a.length + 1];

        post[a.length] = 0;

        for (int i = a.length - 1; i >= 0; i++) {

            post[i] = post[i + 1] + a[i];

        }

        return post;

    }

    static long[] suffix(long[] a) {

        long[] post = new long[a.length + 1];

        post[a.length] = 0;

        for (int i = a.length - 1; i >= 0; i++) {

            post[i] = post[i + 1] + a[i];

        }

        return post;

    }

    // --------------ARRAYS-----------------//

    // --------------Sieve&Factors-----------------//

    static List<Integer> sieveOfEratosthenes(int n) {

        List<Integer> primeList = new ArrayList<>();

        boolean prime[] = new boolean[n + 1];

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

            prime[i] = true;

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

            if (prime[p] == true) {

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

                    prime[i] = false;

            }

        }

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

            if (prime[i] == true)

                primeList.add(i);

            // System.out.print(i + " ");

        }

        return primeList;

    }

    static List<Integer> allDivisors(int n) {

        List<Integer> divisoers = new ArrayList<>();

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

            if (n % i == 0) {

                divisoers.add(i);

                if (i != n / i) {

                    divisoers.add(n / i);

                }

            }

        }

        return divisoers;

    }

    // --------------Sieve&Factors-----------------//

    // -----------------------------------------------PRECOMPUTE--------------------------------------------------//

    // ---------------------------------------------INPUT&OUTPUT--------------------------------------------------//

    static int i() {

        return in.nextInt();

    }

    static long l() {

        return in.nextLong();

    }

    static double d() {

        return in.nextDouble();

    }

    static String s() {

        return in.nextLine();

    }

    static ArrayList<Integer> inputList(int n) {

        ArrayList<Integer> a = new ArrayList<Integer>(n);

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

            a.add(i());

        return a;

    }

    static ArrayList<Long> inputListLong(int n) {

        ArrayList<Long> a = new ArrayList<Long>(n);

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

            a.add(l());

        return a;

    }

    static int[][] inputWithIdx(int N) {

        int A[][] = new int[N][2];

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

            A[i] = new int[] { in.nextInt(), i };

        }

        return A;

    }

    static int[][] inputMatrix(int N, int M) {

        int A[][] = new int[N][M];

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

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

                A[i][j] = i();

            }

        }

        return A;

    }

    static long[][] inputMatrixLong(int N, int M) {

        long A[][] = new long[N][M];

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

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

                A[i][j] = i();

            }

        }

        return A;

    }

    static int[] input(int N) {

        int A[] = new int[N];

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

            A[i] = in.nextInt();

        }

        return A;

    }

    static Integer[] inputWrapper(int N) {

        Integer A[] = new Integer[N];

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

            A[i] = in.nextInt();

        }

        return A;

    }

    static long[] inputLong(int N) {

        long A[] = new long[N];

        for (int i = 0; i < A.length; i++) {

            A[i] = in.nextLong();

        }

        return A;

    }

    static void p(String s) {

        out.print(s);

    }

    static void p(int s) {

        out.print(s);

    }

    static void p(long s) {

        out.print(s);

    }

    static void p(double s) {

        out.print(s);

    }

    static void p(char s) {

        out.print(s);

    }

    static void pl(String s) {

        out.println(s);

    }

    static void pl(int s) {

        out.println(s);

    }

    static void pl(long s) {

        out.println(s);

    }

    static void pl(double s) {

        out.println(s);

    }

    static void pl(char c) {

        out.println(c);

    }

    static void pl() {

        out.println();

    }

    static void pl(int[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static void pl(long[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static <T> void pl(T[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static <T> void pl(List<T> A) {

        for (T a : A) {

            out.print(a + " ");

        }

        out.println();

    }

    static void pl(Object o) {

        out.println(o);

    }

    static void ps(int s) {

        out.print(s + " ");

    }

    static void ps(long s) {

        out.print(s + " ");

    }

    static void ps(double s) {

        out.print(s + " ");

    }

    static void ps(char c) {

        out.print(c + " ");

    }

    static void yes() {

        pl("YES");

    }

    static void no() {

        pl("NO");

    }

    // ---------------------------------------------INPUT&OUTPUT--------------------------------------------------//

}

  class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {

        br = new BufferedReader(new InputStreamReader(System.in));

    }

    String next() {

        while (st == null || !st.hasMoreElements()) {

            try {

                st = new StringTokenizer(br.readLine());

            } catch (IOException e) {

                e.printStackTrace();

            }

        }

        return st.nextToken();

    }

    char nextChar() {

        return next().charAt(0);

    }

    int nextInt() {

        return Integer.parseInt(next());

    }

    long nextLong() {

        return Long.parseLong(next());

    }

    double nextDouble() {

        return Double.parseDouble(next());

    }

    String nextLine() {

        String str = "";

        try {

            str = br.readLine();

        } catch (IOException e) {

            e.printStackTrace();

        }

        return str;

    }

}

import static java.lang.Math.max;

import static java.lang.Math.min;

import static java.lang.Math.abs;

import java.util.*;

import java.io.*;

import java.math.*;

public final class Main {

    static PrintWriter out = new PrintWriter(System.out);

    static FastReader in = new FastReader();

    static final int MOD1 = (int) (1e9 + 7);

    static final int MOD2 = 998244353;

    static final int inf = Integer.MAX_VALUE;

    static final int minf = Integer.MIN_VALUE;

    static final long linf = 1L << 62;

    public static void main(String[] args){

        int tt = i();

        while (tt-- > 0) {

            solve();

        }

        out.flush();

    }

    public static void solve(){

        // int MIN = -1*(int) 1e9;

        // int MAX = (int) 1e9;

        // PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());

        int n = i();

        int x = i();

        int y = i();

        // String s = s();

        // int ar[]=input(n);

        int ar[]=new int[n];

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

            ar[i]=i&1;

        }

        if(ar[0]==ar[n-1]){

            if(x==n||y==n){

                ar[n-1]=2;

            }

            else

            ar[0]=2;

        }

            if(ar[x-1]==ar[y-1])

            ar[y-1]=2;

        pl(ar);

    }

    static int BinarySearch(long ar[], int k) {

        int lo = 0;

        int hi = ar.length - 1;

        int mid;

        int ans = -1;

        while (lo <= hi) {

            mid = lo + ((hi - lo) / 2);

            if (ar[mid] >= k) {

                ans = mid;

                hi = mid - 1;

            } else {

                lo = mid + 1;

            }

        }

        return ans;

    }

    // ------------------------------------------COMMON|FUNCTIONS--------------------------------------------------//

    // -------------BINARYSEARCH-----------//

    // UPPERBOUND find lowest i which satisfy a[i]>=x

    static int upperbound(List<Integer> a, int x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a.get(m) >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(List<Long> a, long x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a.get(m) >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(int[] a, int x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a[m] >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    static int upperbound(long[] a, long x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = l + (r - l) / 2;

            if (a[m] >= x) {

                r = m;

            } else {

                l = m + 1;

            }

        }

        return r;

    }

    // LOWERBOUND find highest i which satisfy a[i]<=x

    static int lowerbound(List<Long> a, long x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a.get(m) <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(List<Integer> a, int x) {

        int l = 0;

        int r = a.size() - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a.get(m) <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(int[] a, int x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a[m] <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    static int lowerbound(long[] a, long x) {

        int l = 0;

        int r = a.length - 1;

        while (l < r) {

            int m = (l + r + 1) / 2;

            if (a[m] <= x) {

                l = m;

            } else {

                r = m - 1;

            }

        }

        return l;

    }

    // -------------BINARYSEARCH-----------//

    // ---------------MATH-----------------//

    public static long fact(int n, int mod) {

        long res = 1;

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

            res = (res * i) % mod;

        }

        return res;

    }

    static int GCD(int a, int b) {

        int dividend = a > b ? a : b;

        int divisor = a < b ? a : b;

        while (divisor > 0) {

            int reminder = dividend % divisor;

            dividend = divisor;

            divisor = reminder;

        }

        return dividend;

    }

    static long GCD(long a, long b) {

        long dividend = a > b ? a : b;

        long divisor = a < b ? a : b;

        while (divisor > 0) {

            long reminder = dividend % divisor;

            dividend = divisor;

            divisor = reminder;

        }

        return dividend;

    }

    static long LCM(int a, int b) {

        return (long) a / GCD(a, b) * b;

    }

    static long LCM(long a, long b) {

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

    }

    static long pow(long a, long b, int mod) {

        long pow = 1;

        long x = a;

        while (b != 0) {

            if ((b & 1) != 0) {

                pow = (pow * x) % mod;

            }

            x = (x * x) % mod;

            b /= 2;

        }

        return pow;

    }

    static long pow(long a, long b) {

        long pow = 1;

        long x = a;

        while (b != 0) {

            if ((b & 1) != 0) {

                pow *= x;

            }

            x = x * x;

            b /= 2;

        }

        return pow;

    }

    static long modInverse(long x, int mod) {

        return pow(x, mod - 2, mod);

    }

    static boolean isPrime(long N) {

        if (N <= 1) {

            return false;

        }

        if (N <= 3) {

            return true;

        }

        if (N % 2 == 0 || N % 3 == 0) {

            return false;

        }

        for (int i = 5; i * i <= N; i = i + 6) {

            if (N % i == 0 || N % (i + 2) == 0) {

                return false;

            }

        }

        return true;

    }

    static long log(long a) {

        return (long) (Math.log(a));

    }

    static long log2(long a) {

        return (long) (Math.log(a) / Math.log(2));

    }

    static long sqrt(long x) {

        long start = 0, end = (long) 3e9, ans = 1;

        while (start <= end) {

            long mid = (start + end) / 2;

            if (mid * mid <= x) {

                ans = mid;

                start = mid + 1;

            } else

                end = mid - 1;

        }

        return ans;

    }

    static long ceil(long a, long b) {

        return (a / b) + ((a % b == 0) ? 0 : 1);

    }

    static boolean isPerfectSquare(double number) {

        double sqrt = Math.sqrt(number);

        return ((sqrt - Math.floor(sqrt)) == 0);

    }

    // ---------------MATH-----------------//

    // ---------------CALCS-----------------//

    static long sum(List<Long> a) {

        long sum = 0;

        for (long ele : a)

            sum += ele;

        return sum;

    }

    static long sum(int[] a) {

        long sum = 0;

        for (int ele : a)

            sum += ele;

        return sum;

    }

    static long sum(long[] a) {

        long sum = 0;

        for (long ele : a)

            sum += ele;

        return sum;

    }

    static int maxArray(long a[]) {

        int in = 0;

        long m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] > m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int maxArray(int a[]) {

        int in = 0;

        int m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] > m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int minArray(long a[]) {

        int in = 0;

        long m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] < m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    static int minArray(int a[]) {

        int in = 0;

        int m = a[0];

        for (int i = 1; i < a.length; i++) {

            if (a[i] < m) {

                m = a[i];

                in = i;

            }

        }

        return in;

    }

    // ---------------CALCS-----------------//

    // ------------------------------------------COMMON|FUNCTIONS--------------------------------------------------//

    // ------------------------------------------MODIFICATIONS--------------------------------------------------//

    static void shuffle(int[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            int temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

    }

    static void shuffleAndSort(int[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            int temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

        Arrays.sort(arr);

    }

    static void shuffleAndSort(long[] arr) {

        for (int i = 0; i < arr.length; i++) {

            int rand = (int) (Math.random() * arr.length);

            long temp = arr[rand];

            arr[rand] = arr[i];

            arr[i] = temp;

        }

        Arrays.sort(arr);

    }

    static void swap(int A[], int a, int b) {

        int t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    static void swap(long A[], int a, int b) {

        long t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    static void swap(char A[], int a, int b) {

        char t = A[a];

        A[a] = A[b];

        A[b] = t;

    }

    public static String reverse(String str) {

        if (str == null) {

            return null;

        }

        return new StringBuilder(str).reverse().toString();

    }

    public static void reverse(int[] arr) {

        int l = 0;

        int r = arr.length - 1;

        while (l < r) {

            swap(arr, l, r);

            l++;

            r--;

        }

    }

    public static void reverse(long[] arr) {

        int l = 0;

        int r = arr.length - 1;

        while (l < r) {

            swap(arr, l, r);

            l++;

            r--;

        }

    }

    public static String repeat(char ch, int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

        for (int i = repeat - 1; i >= 0; i--) {

            buf[i] = ch;

        }

        return new String(buf);

    }

    public static String repeat(char ch[], int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

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

            buf[i] = ch[i % ch.length];

        }

        return new String(buf);

    }

    public static String repeat(String ch, int repeat) {

        if (repeat <= 0) {

            return "";

        }

        final char[] buf = new char[repeat];

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

            buf[i] = ch.charAt(i % ch.length());

        }

        return new String(buf);

    }

    static void fillFrequency(Map<Long, Integer> map, long a[]) {

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

            fill(map, a[i]);

        }

    }

    static void fill(Map<Long, Integer> map, long val) {

        if (map.containsKey(val))

            map.put(val, map.get(val) + 1);

        else

            map.put(val, 1);

    }

    static void fillFrequency(Map<Integer, Integer> map, int a[]) {

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

            fill(map, a[i]);

        }

    }

    static void fill(Map<Integer, Integer> map, int val) {

        if (map.containsKey(val))

            map.put(val, map.get(val) + 1);

        else

            map.put(val, 1);

    }

    static void remove(Map<Long, Integer> map, long val) {

        if (map.get(val) == 1)

            map.remove(val);

        else

            map.replace(val, map.get(val) - 1);

    }

    static void remove(Map<Integer, Integer> map, int val) {

        if (map.get(val) == 1)

            map.remove(val);

        else

            map.replace(val, map.get(val) - 1);

    }

    // ------------------------------------------MODIFICATIONS--------------------------------------------------//    // -----------------------------------------------PRECOMPUTE--------------------------------------------------//

    // --------------BITS-----------------//

    static int[][] PrefixBitsCount(int n, int[] a) {

        int pref[][] = new int[n + 1][32];

        // Builds the prefix sums for each bit

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

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

                if ((a[i] & (1 << j)) != 0) {

                    pref[i + 1][j] = pref[i][j] + 1;

                } else {

                    pref[i + 1][j] = pref[i][j];

                }

            }

        }

        return pref;

    }

    static int[] prefixAnd(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] & a[i];

        }

        return pre;

    }

    static int[] prefixOr(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] | a[i];

        }

        return pre;

    }

    static int[] prefixXor(int[] a) {

        int[] pre = new int[a.length];

        pre[0] = a[0];

        for (int i = 1; i < a.length; i++) {

            pre[i] = pre[i - 1] ^ a[i];

        }

        return pre;

    }

    // --------------BITS-----------------//

    // --------------ARRAYS-----------------//

    static int[] getPrefMax(int arr[]) {

        int n = arr.length;

        int pref[] = new int[n];

        pref[0] = arr[0];

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

            pref[i] = max(arr[i], pref[i - 1]);

        }

        return pref;

    }

    static int[] getPrefMin(int arr[]) {

        int n = arr.length;

        int pref[] = new int[n];

        pref[0] = arr[0];

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

            pref[i] = min(arr[i], pref[i - 1]);

        }

        return pref;

    }

    static int[] getSuffMin(int arr[]) {

        int n = arr.length;

        int suff[] = new int[n];

        suff[n - 1] = arr[n - 1];

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

            suff[i] = min(suff[i + 1], arr[i]);

        }

        return suff;

    }

    static long[] prefix(int[] a) {

        long[] pre = new long[a.length + 1];

        pre[0] = 0;

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

            pre[i + 1] = pre[i] + a[i];

        }

        return pre;

    }

    static List<Long> prefix(List<Integer> a) {

        List<Long> pre = new ArrayList<>();

        pre.add(0l);

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

            pre.add(pre.get(i) + a.get(i));

        }

        return pre;

    }

    static long[] prefix(long[] a) {

        long[] pre = new long[a.length + 1];

        pre[0] = 0;

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

            pre[i + 1] = pre[i] + a[i];

        }

        return pre;

    }

    static long[] suffix(int[] a) {

        long[] post = new long[a.length + 1];

        post[a.length] = 0;

        for (int i = a.length - 1; i >= 0; i++) {

            post[i] = post[i + 1] + a[i];

        }

        return post;

    }

    static long[] suffix(long[] a) {

        long[] post = new long[a.length + 1];

        post[a.length] = 0;

        for (int i = a.length - 1; i >= 0; i++) {

            post[i] = post[i + 1] + a[i];

        }

        return post;

    }

    // --------------ARRAYS-----------------//

    // --------------Sieve&Factors-----------------//

    static List<Integer> sieveOfEratosthenes(int n) {

        List<Integer> primeList = new ArrayList<>();

        boolean prime[] = new boolean[n + 1];

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

            prime[i] = true;

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

            if (prime[p] == true) {

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

                    prime[i] = false;

            }

        }

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

            if (prime[i] == true)

                primeList.add(i);

            // System.out.print(i + " ");

        }

        return primeList;

    }

    static List<Integer> allDivisors(int n) {

        List<Integer> divisoers = new ArrayList<>();

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

            if (n % i == 0) {

                divisoers.add(i);

                if (i != n / i) {

                    divisoers.add(n / i);

                }

            }

        }

        return divisoers;

    }

    // --------------Sieve&Factors-----------------//

    // -----------------------------------------------PRECOMPUTE--------------------------------------------------//

    // ---------------------------------------------INPUT&OUTPUT--------------------------------------------------//

    static int i() {

        return in.nextInt();

    }

    static long l() {

        return in.nextLong();

    }

    static double d() {

        return in.nextDouble();

    }

    static String s() {

        return in.nextLine();

    }

    static ArrayList<Integer> inputList(int n) {

        ArrayList<Integer> a = new ArrayList<Integer>(n);

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

            a.add(i());

        return a;

    }

    static ArrayList<Long> inputListLong(int n) {

        ArrayList<Long> a = new ArrayList<Long>(n);

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

            a.add(l());

        return a;

    }

    static int[][] inputWithIdx(int N) {

        int A[][] = new int[N][2];

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

            A[i] = new int[] { in.nextInt(), i };

        }

        return A;

    }

    static int[][] inputMatrix(int N, int M) {

        int A[][] = new int[N][M];

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

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

                A[i][j] = i();

            }

        }

        return A;

    }

    static long[][] inputMatrixLong(int N, int M) {

        long A[][] = new long[N][M];

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

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

                A[i][j] = i();

            }

        }

        return A;

    }

    static int[] input(int N) {

        int A[] = new int[N];

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

            A[i] = in.nextInt();

        }

        return A;

    }

    static Integer[] inputWrapper(int N) {

        Integer A[] = new Integer[N];

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

            A[i] = in.nextInt();

        }

        return A;

    }

    static long[] inputLong(int N) {

        long A[] = new long[N];

        for (int i = 0; i < A.length; i++) {

            A[i] = in.nextLong();

        }

        return A;

    }

    static void p(String s) {

        out.print(s);

    }

    static void p(int s) {

        out.print(s);

    }

    static void p(long s) {

        out.print(s);

    }

    static void p(double s) {

        out.print(s);

    }

    static void p(char s) {

        out.print(s);

    }

    static void pl(String s) {

        out.println(s);

    }

    static void pl(int s) {

        out.println(s);

    }

    static void pl(long s) {

        out.println(s);

    }

    static void pl(double s) {

        out.println(s);

    }

    static void pl(char c) {

        out.println(c);

    }

    static void pl() {

        out.println();

    }

    static void pl(int[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static void pl(long[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static <T> void pl(T[] o) {

        for (int i = 0; i < o.length; i++) {

            out.print(o[i] + " ");

        }

        out.println();

    }

    static <T> void pl(List<T> A) {

        for (T a : A) {

            out.print(a + " ");

        }

        out.println();

    }

    static void pl(Object o) {

        out.println(o);

    }

    static void ps(int s) {

        out.print(s + " ");

    }

    static void ps(long s) {

        out.print(s + " ");

    }

    static void ps(double s) {

        out.print(s + " ");

    }

    static void ps(char c) {

        out.print(c + " ");

    }

    static void yes() {

        pl("YES");

    }

    static void no() {

        pl("NO");

    }

    // ---------------------------------------------INPUT&OUTPUT--------------------------------------------------//

}

  class FastReader {

    BufferedReader br;

    StringTokenizer st;

    public FastReader() {

        br = new BufferedReader(new InputStreamReader(System.in));

    }

    String next() {

        while (st == null || !st.hasMoreElements()) {

            try {

                st = new StringTokenizer(br.readLine());

            } catch (IOException e) {

                e.printStackTrace();

            }

        }

        return st.nextToken();

    }

    char nextChar() {

        return next().charAt(0);

    }

    int nextInt() {

        return Integer.parseInt(next());

    }

    long nextLong() {

        return Long.parseLong(next());

    }

    double nextDouble() {

        return Double.parseDouble(next());

    }

    String nextLine() {

        String str = "";

        try {

            str = br.readLine();

        } catch (IOException e) {

            e.printStackTrace();

        }

        return str;

    }

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

const int N = 2e5+7;

int a[N];

int main(){

	ios::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 m=y-x,flag=0;

		if (n%2==0){

			if (m%2){

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

			}

			else{

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

				a[y]=2;

			}

		}

		else{

			if (m%2){

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

				a[x]=2;

			}

			else{

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

				a[x]=2;

			}

		}

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

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

		cout<<"\n";

	}

	return 0;

}

#include<bits/stdc++.h>

using namespace std;

const int N = 2e5+7;

int a[N];

int main(){

	ios::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 m=y-x,flag=0;

		if (n%2==0){

			if (m%2){

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

			}

			else{

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

				a[y]=2;

			}

		}

		else{

			if (m%2){

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

				else a[x-1]=2;

			}

			else{

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

					a[i]=flag;

					if (flag==0) flag=1;

					else flag=0;

				}

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

				else a[x-1]=2;

				a[y]=2;

			}

		}

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

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

		cout<<"\n";

	}

	return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

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

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

#define mll map<ll,ll>

#define vl vector<ll>

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

#define cnt(a,v) count(a.begin(),a.end(),v)

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

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}

void solve() {

	ll n; cin>>n;

	ll x,y; cin>>x>>y; x--; y--;

	vl ans(n);

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

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

		{

			ans[i] = 1&i;

		}

	}

	else{

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

		{

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

			else ans[i] = ((i-x+n)%n)&1;

		}

	}

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

	{

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

	}

	cout<<ln;

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define N 100000000+1;

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

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

#define mll map<ll,ll>

#define vl vector<ll>

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

#define cnt(a,v) count(a.begin(),a.end(),v)

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

#define ln "\n"

#define Griffith ios_base::sync_with_stdio(0);

#define The cin.tie(0);

#define Hawk cout.tie(0);

#define Solve ll tt; cin>>tt; while (tt--){solve();	}

void solve() {

	ll n; cin>>n;

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

	vl ans(n);

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

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

		{

			ans[i] = 1&i;

		}

	}

	else{

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

		{

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

			else ans[i] = ((i-x+n)%n)&1;

		}

	}

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

	{

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

	}

	cout<<ln;

}

int main(){

	Griffith The Hawk

	Solve

	//solve();

	return 0;

}

Answer: 1


// || =================================================================== ||

// ||                                                                     ||

// ||                   Reach Expert by May 2025                          ||

// ||                                                                     ||

// || =================================================================== ||

#include <bits/stdc++.h>

#define int long long

#define endl "\n";

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

#define ONLINE_JUDGE

using namespace std;

long long mod_exp(long long base, long long exp, long long mod) {

    long long result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

int m(set<int> arr){

	int st = 0;

	for(auto i : arr){

		if(i == st){

			// then do nothing

		}else{

			return st;

		}

		st++;

	}

	return st;

}

void solve() {

    int n, x, y;

	cin >> n >> x >> y;

	// vector<set<int>> f(n + 1);

	vector<int> ans(n + 1);

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

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

		else ans[i] = 1;

	}

	if((x + y) & 1){

		// i think it does not matter in case of even n is even only

		if(n % 2 == 0){

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

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

			}

			cout << endl;

		}else{

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

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

			}

			ans[n] = 2;

			cout << 2;

			cout << endl;

		}

	}else{

		// same number having people are friends

		// so one among them need to have 2 as ans[]

		if(n % 2 == 0){

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

				if(i == x){

					cout << 2 << " ";

					ans[i] = 2;

				}else {

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

				}

			}

			cout << endl;

		}else{

			ans[x] = 2;

			int idx = x - 1;

			if(idx == 0) idx = n;

			int cnt = 1;

			int val = 0;

			while(cnt < n){

				ans[idx] = val;

				val = !val;

				cnt++;

				idx--;

				if(idx == 0) idx = n;

			}

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

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

			}

			cout << endl;

		}

	}

	//validation

	vector<set<int>> f(n + 1);

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

		int nxt = i + 1;

		int prev = i - 1;

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

		if(prev == 0) prev = n;

		f[i].insert(nxt);

		f[i].insert(prev);

	}

	f[x].insert(y);

	f[y].insert(x);

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

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

	// cout << endl;

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

		set<int> friendsMx;

		// cout << "friends of " << i << " : " ;

		for(auto j : f[i]){

			// cout << j << " , " << ans[j] << " ; ";

			friendsMx.insert(ans[j]);

		}

		// cout << endl;

		// cout << "M value for " << i << " is " << m(friendsMx) << endl;

		// cout << "Ans value for " << i << " is " << ans[i] << endl;

		int m_val = m(friendsMx);

		if(m_val != ans[i]){

			cout << "wrong for " << i << endl;

		}

	}

}

signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    int t;

    cin >> t;

    while(t--)

        solve();

}

/*

void solve() {

    int n, k;

    cin >> n >> k;

    int r = n, l  =1;

	stack<pair<int,int>> st;

	st.push({l, r});

	int ans =0LL;

	while(st.size()){

		auto p = st.top();

		st.pop();

		int curL = p.first;

		int curR = p.second;

		if(curR - curL + 1 < k){

			// do nothing

		}else{

			int sz = curR - curL + 1;

			if(sz & 1){

				int m = (curL + curR) / 2LL;

				ans += m;

				cout << "{" << curL << " , " << curR << "} : " << m << endl;

				st.push({curL, m - 1LL});

				st.push({m + 1LL , curR});

			}else{

				int m = (curL + curR) / 2LL;

				st.push({curL, m});

				st.push({m + 1LL , curR});

			}

		}

	}

	cout << ans << endl;

}

 */

// || =================================================================== ||

// ||                                                                     ||

// ||                   Reach Expert by May 2025                          ||

// ||                                                                     ||

// || =================================================================== ||

#include <bits/stdc++.h>

#define int long long

#define endl "\n";

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

#define ONLINE_JUDGE

using namespace std;

long long mod_exp(long long base, long long exp, long long mod) {

    long long result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

int m(set<int> arr){

	int st = 0;

	for(auto i : arr){

		if(i == st){

			// then do nothing

		}else{

			return st;

		}

		st++;

	}

	return st;

}

void solve() {

    int n, x, y;

	cin >> n >> x >> y;

	// vector<set<int>> f(n + 1);

	vector<int> ans(n + 1);

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

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

		else ans[i] = 1;

	}

	if((x + y) & 1){

		// i think it does not matter in case of even n is even only

		if(n % 2 == 0){

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

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

			}

			cout << endl;

		}else{

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

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

			}

			ans[n] = 2;

			cout << 2;

			cout << endl;

		}

	}else{

		// same number having people are friends

		// so one among them need to have 2 as ans[]

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

			if(i == x){

				cout << 2 << " ";

				ans[i] = 2;

			}else {

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

			}

		}

		cout << endl;

	}

	//validation

	vector<set<int>> f(n + 1);

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

		int nxt = i + 1;

		int prev = i - 1;

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

		if(prev == 0) prev = n;

		f[i].insert(nxt);

		f[i].insert(prev);

	}

	f[x].insert(y);

	f[y].insert(x);

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

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

	// cout << endl;

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

		set<int> friendsMx;

		// cout << "friends of " << i << " : " ;

		for(auto j : f[i]){

			// cout << j << " , " << ans[j] << " ; ";

			friendsMx.insert(ans[j]);

		}

		// cout << endl;

		// cout << "M value for " << i << " is " << m(friendsMx) << endl;

		// cout << "Ans value for " << i << " is " << ans[i] << endl;

		int m_val = m(friendsMx);

		if(m_val != ans[i]){

			cout << "wrong for " << i << endl;

		}

	}

}

signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    int t;

    cin >> t;

    while(t--)

        solve();

}

/*

void solve() {

    int n, k;

    cin >> n >> k;

    int r = n, l  =1;

	stack<pair<int,int>> st;

	st.push({l, r});

	int ans =0LL;

	while(st.size()){

		auto p = st.top();

		st.pop();

		int curL = p.first;

		int curR = p.second;

		if(curR - curL + 1 < k){

			// do nothing

		}else{

			int sz = curR - curL + 1;

			if(sz & 1){

				int m = (curL + curR) / 2LL;

				ans += m;

				cout << "{" << curL << " , " << curR << "} : " << m << endl;

				st.push({curL, m - 1LL});

				st.push({m + 1LL , curR});

			}else{

				int m = (curL + curR) / 2LL;

				st.push({curL, m});

				st.push({m + 1LL , curR});

			}

		}

	}

	cout << ans << endl;

}

 */

Answer: 1


#include <iostream>

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;

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

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

void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

    bool f = x&1?1:0;

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

        ans[i] = (i&1?f:!f);

    }

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

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

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

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

    int T = 1 ;

    cin >> T;

    while (T--){

        PLAY();

    }

    return 0;

}

#include <iostream>

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;

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

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

void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

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

    }

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

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

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

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

    int T = 1 ;

    cin >> T;

    while (T--){

        PLAY();

    }

    return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> res(n + 1);

    if (n % 2) {

        bool ok = false;

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

            if (i == y && (y - x) % 2 == 0) ok = true;

            res[i] = (i + ok) % 2;

        }

        res[y] = 2;

    }

    else {

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

            res[i] = i % 2;

        }

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

    }

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

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

void solve(){

    int n, x, y;

    cin >> n >> x >> y;

    vector<int> res(n + 1);

    if (n % 2) {

        bool ok = false;

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

            if (i == y) ok = true;

            res[i] = (i + ok) % 2;

        }

        res[y] = 2;

    }

    else {

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

            res[i] = i % 2;

        }

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

    }

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

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

    return 0;

}

Answer: 2


#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define int long long

#define ok cout<<"ok\n"

using namespace std;

typedef pair<int,int> PII;

#define ft first

#define sd second

const int N=1e6+10;

const int mod=998244353;

//const int inf=0x3f3f3f3f;

const int inf=0x3f3f3f3f3f3f3f3f;

int n,m;

int a[N];

void solve(){

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

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

		a[i]=0;

		a[i+1]=1;

	}

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

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

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

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

	cout<<'\n';

}

signed main(){

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

	int Case=1;

	cin>>Case;

	while(Case--)solve();

}

#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define int long long

#define ok cout<<"ok\n"

using namespace std;

typedef pair<int,int> PII;

#define ft first

#define sd second

const int N=1e6+10;

const int mod=998244353;

//const int inf=0x3f3f3f3f;

const int inf=0x3f3f3f3f3f3f3f3f;

int n,m;

int a[N];

void solve(){

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

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

		a[i]=0;

		a[i+1]=1;

	}

	if(n%2==0){

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

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

	}

	else{

		a[x]=2;

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

		for(int i=x-1;i>=1;i-=2)a[i]=1,a[i-1]=0;

	}

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

	cout<<'\n';

}

signed main(){

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

	int Case=1;

	cin>>Case;

	while(Case--)solve();

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=100000;

vector<int> v;

int CALMEX(vector<int> sex){

	int m[10]={};

	for(auto k:sex){

		m[k]++;

	}

	if(m[0]==0){

		return 0;

	}

	if(m[1]==0){

		return 1;

	}

	if(m[2]==0){

		return 2;

	}

	if(m[3]==0){

		return 3;

	}

	return 4;

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	int a[n+2]={},b[n+2]={};

	vector<vector<int>> g(n+2);

	g[x].push_back(y);

	g[y].push_back(x);

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

		g[i].push_back(i-1);

		g[i].push_back(i+1);

	}

	g[1].push_back(n);

	g[1].push_back(2);

	g[n].push_back(1);

	g[n].push_back(n-1);

	int thu=10;

	while(thu--){

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

		for(auto x:g[i]){

		//	cout<<a[x]<<" ";

			v.push_back(a[x]);

		}

		a[i]=CALMEX(v);

		v.clear();

	}

}

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

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

	}

	cout<<'\n';

}

int main(){

	#define task ""

	if(fopen(task".inp", "r")){

		freopen(task".inp", "r", stdin);

		freopen(task".out", "w", stdout);

	}

	ios_base::sync_with_stdio(0);

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

	int t;

	cin>>t;

	while(t--){

		solve();

	}

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=100000;

vector<int> v;

int CALMEX(vector<int> sex){

	int m[10]={};

	for(auto k:sex){

		m[k]++;

	}

	if(m[0]==0){

		return 0;

	}

	if(m[1]==0){

		return 1;

	}

	if(m[2]==0){

		return 2;

	}

	if(m[3]==0){

		return 3;

	}

	return 4;

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	int a[n+2]={};

	vector<vector<int>> g(n+2);

	g[x].push_back(y);

	g[y].push_back(x);

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

		g[i].push_back(i-1);

		g[i].push_back(i+1);

	}

	g[1].push_back(n);

	g[1].push_back(2);

	g[n].push_back(1);

	g[n].push_back(n-1);

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

		for(auto x:g[i]){

		//	cout<<a[x]<<" ";

			v.push_back(a[x]);

		}

		a[i]=CALMEX(v);

		v.clear();

	}

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

		for(auto x:g[i]){

		//	cout<<a[x]<<" ";

			v.push_back(a[x]);

		}

		a[i]=CALMEX(v);

		v.clear();

	}

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

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

	}

	cout<<'\n';

}

int main(){

	#define task ""

	if(fopen(task".inp", "r")){

		freopen(task".inp", "r", stdin);

		freopen(task".out", "w", stdout);

	}

	ios_base::sync_with_stdio(0);

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

	int t;

	cin>>t;

	while(t--){

		solve();

	}

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define sws std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define int long long int

#define float long double

#define ld long double

#define ll long long

#define pb push_back

#define ff first

#define ss second

#define vi vector<int>

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

#define vvi vector<vector<int>>

#define pii pair<int, int>

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

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

#define in(v) for(auto & x : v) cin >> x;

#define out(v) for(auto x : v) cout << x << ' ';

#define tiii tuple<int, int, int>

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

const int MAX = 3e5+1;

const int INF = INT32_MAX;

int MOD = 1e9+7;

const int LOG = 31;

const ld PI = acos(-1);

const int MINF = INT32_MIN;

vpii dirs = {{1, 0}, {-1, 0}};

vpii dirs1 = {{0, 1}, {0, -1}};

// Contest patrocinado por Summer

// meu primeiro amor santos queridooooooo

void solve() {

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

    x--; y--;

    vi ans(n, -1);

    if(n % 2){

        ans[x] = 2;

        int start = 1;

        for(int i = (x + 1) % n; ans[i] == -1; (i+=1)%=n){

            ans[i] = start;

            start = !(start == 1);

        }

        cout << '\n';

        out(ans);

        cout << '\n';

        return;

    }

    if(x % 2 == y % 2) {ans[x] = 2;}

    int start = 1, iniPoint = x;

    for(int i = (iniPoint + 1) % n; ans[i] > 2 || ans[i] == -1; (i+=1)%=n){

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

        ans[i] = start;

        start = !(start == 1);

    }

    cout << '\n';

    out(ans);

    cout << '\n';

}

int32_t main() {

    sws;

    int t = 1;

    cin >> t;

    while(t--)

        solve();

return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define sws std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define int long long int

#define float long double

#define ld long double

#define ll long long

#define pb push_back

#define ff first

#define ss second

#define vi vector<int>

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

#define vvi vector<vector<int>>

#define pii pair<int, int>

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

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

#define in(v) for(auto & x : v) cin >> x;

#define out(v) for(auto x : v) cout << x << ' ';

#define tiii tuple<int, int, int>

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

const int MAX = 3e5+1;

const int INF = INT32_MAX;

int MOD = 1e9+7;

const int LOG = 31;

const ld PI = acos(-1);

const int MINF = INT32_MIN;

vpii dirs = {{1, 0}, {-1, 0}};

vpii dirs1 = {{0, 1}, {0, -1}};

// Contest patrocinado por Summer

// meu primeiro amor santos queridooooooo

void solve() {

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

    x--; y--;

    vi ans(n, -1);

        ans[x] = 2;

        int start = 1;

        for(int i = (x + 1) % n; ans[i] == -1; (i+=1)%=n){

            ans[i] = start;

            start = !(start == 1);

        }

        cout << '\n';

        out(ans);

        cout << '\n';

        return;

    if(x % 2 == y % 2) {ans[x] = 2; ans[y] = 3;}

    start = 1;

    int iniPoint = x;

    if(y - x - 1 == 1){

        ans[x + 1] = 0;

        iniPoint = y;

    }

    for(int i = (iniPoint + 1) % n; ans[i] > 2 || ans[i] == -1; (i+=1)%=n){

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

        ans[i] = start;

        start = !(start == 1);

    }

    cout << '\n';

    out(ans);

    cout << '\n';

}

int32_t main() {

    sws;

    int t = 1;

    cin >> t;

    while(t--)

        solve();

return 0;

}

Answer: 1


#include<bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n,x,y;

int ans[N];

void solve()

{

	cin>>n>>x>>y;

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

		if(n&1){

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

				if(i&1) cout <<1<<" ";

				else cout <<0<<" ";

			}

			cout <<2<<'\n';

		}else{

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

				if(i&1) cout <<1<<" ";

				else cout <<0<<" ";

			}

			cout <<'\n';

		}

	}else{

		if(n&1){

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

				if(i == x){

					cout <<2<<" ";

				}else{

					if(cnt&1) cout <<0<<" ";

					else cout <<1<<" ";

					cnt++;

				}

			}

			cout <<'\n';

		}else{

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

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

				else ans[i] = 0;

			}

			ans[x] = 2;

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

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

			}

			cout <<'\n';

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

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

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0;

}

#include<bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n,x,y;

int ans[N];

void solve()

{

	cin>>n>>x>>y;

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

		cout <<2<<" ";

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

			if(i&1) cout <<0<<" ";

			else cout <<1<<" ";

		}

		cout <<'\n';

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

		ans[x] = 2;

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

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

			else ans[i] = 1;

		}

		for(int i = x-1,cnt = 0;i>=1;i--,cnt++){

			if(cnt&1) ans[i] = 1;

			else ans[i] = 0;

		}

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

		cout <<'\n';

	}

}

int main()

{

	ios::sync_with_stdio(false);

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

	int t;

	cin>>t;

	while(t--)

	{

		solve();

	}

	return 0;

}

Answer: 1


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;

#define endl "\n"

#define ll long long

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr);

const int N = 2e5 + 5;

int ans[N];

int main() {

    IOS;

    int t;

    cin >> t;

    while (t--) {

        int n, x, y;

        cin >> n >> x >> y;

        x--, y--;

        if (x > y) {

            swap(x, y);

        }

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

            ans[i] = -1;

        }

        int i;

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

            ans[0] = 0;

            i = 1;

            x = 0;

        } else {

            ans[x] = 0;

            ans[y] = 1;

            int xa = (x + 1) % n, xb = (x - 1 + n) % n;

            int ya = (y + 1) % n, yb = (y - 1 + n) % n;

            ans[xa] = 1;

            ans[xb] = 1;

            ans[ya] = 0;

            ans[yb] = 0;

            if (xa == ya || xa == yb) {

                ans[xa] = 2;

            }

            if (xb == ya || xb == yb) {

                ans[xb] = 2;

            }

        }

        while (i != x) {

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

                set<int> st;

                if (ans[(i - 1 + n) % n] != -1) {

                    st.insert(ans[(i - 1 + n) % n]);

                }

                if (ans[(i + 1) % n] != -1) {

                    st.insert(ans[(i + 1) % n]);

                }

                if (*st.begin() == 1) {

                    ans[i] = 0;

                } else if (*st.rbegin() == 0 || st.size() == 1) {

                    ans[i] = 1;

                } else {

                    ans[i] = 2;

                }

            }

            i = (i + 1) % n;

        }

        i = x;

        while (i != y) {

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

                set<int> st;

                if (ans[(i - 1 + n) % n] != -1) {

                    st.insert(ans[(i - 1 + n) % n]);

                }

                if (ans[(i + 1) % n] != -1) {

                    st.insert(ans[(i + 1) % n]);

                }

                if (*st.begin() == 1) {

                    ans[i] = 0;

                } else if (*st.rbegin() == 0 || st.size() == 1) {

                    ans[i] = 1;

                } else {

                    ans[i] = 2;

                }

            }

            i++;

        }

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

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

        }

        cout << endl;

    }

    return 0;

}

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;

#define endl "\n"

#define ll long long

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr);

const int N = 2e5 + 5;

int ans[N];

int main() {

    IOS;

    int t;

    cin >> t;

    while (t--) {

        int n, x, y;

        cin >> n >> x >> y;

        x--, y--;

        if (x > y) {

            swap(x, y);

        }

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

            ans[i] = -1;

        }

        int i;

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

            ans[0] = 0;

            i = 1;

            x = 0;

        } else {

            ans[x] = 0;

            ans[y] = 1;

            int xa = (x + 1) % n, xb = (x - 1 + n) % n;

            int ya = (y + 1) % n, yb = (y - 1 + n) % n;

            ans[xa] = 1;

            ans[xb] = 1;

            ans[ya] = 0;

            ans[yb] = 0;

            if (xa == ya || xa == yb) {

                ans[xa] = 2;

            }

            if (xb == ya || xb == yb) {

                ans[xb] = 2;

            }

            i = y;

        }

        while (i != x) {

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

                set<int> st;

                if (ans[(i - 1 + n) % n] != -1) {

                    st.insert(ans[(i - 1 + n) % n]);

                }

                if (ans[(i + 1) % n] != -1) {

                    st.insert(ans[(i + 1) % n]);

                }

                if (*st.begin() == 1) {

                    ans[i] = 0;

                } else if (*st.rbegin() == 0 || st.size() == 1) {

                    ans[i] = 1;

                } else {

                    ans[i] = 2;

                }

            }

            i = (i + 1) % n;

        }

        i = x;

        while (i != y) {

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

                set<int> st;

                if (ans[(i - 1 + n) % n] != -1) {

                    st.insert(ans[(i - 1 + n) % n]);

                }

                if (ans[(i + 1) % n] != -1) {

                    st.insert(ans[(i + 1) % n]);

                }

                if (*st.begin() == 1) {

                    ans[i] = 0;

                } else if (*st.rbegin() == 0 || st.size() == 1) {

                    ans[i] = 1;

                } else {

                    ans[i] = 2;

                }

            }

            i++;

        }

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

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

        }

        cout << endl;

    }

    return 0;

}

Answer: 2


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long ll;

typedef vector<ll> vi;

typedef vector<char> vc;

typedef vector<long long> vll;

typedef unsigned long long ull;

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

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

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

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

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

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

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

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

#define pb push_back

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

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

#define mp make_pair

#define ff first

#define ss second

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

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

#define INF 1e9

#define MOD 1000000007

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

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

#ifndef ONLINE_JUDGE

    #include "Jatt_don't_Care.h"

#else

    #define see(...) 42

#endif

void solve() {

ll n,x,y;

cin>>n>>x>>y;

x--,y--;

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

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

    return;

}

ll c=0;

for1(i,0,n){

    if(x==i){

        cout<<2<<" ";

        if(n%2==0){

        c+=1;

        c%=2;

        }

        continue;

    }

    cout<<c<<" ";

    c++;

    c%=2;

}

cout<<"\n";

}

signed main() {

   Code_by_Millenialkiid

   ll t;

    cin >> t;

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

        #ifndef ONLINE_JUDGE

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

        #endif

       solve();

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long ll;

typedef vector<ll> vi;

typedef vector<char> vc;

typedef vector<long long> vll;

typedef unsigned long long ull;

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

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

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

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

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

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

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

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

#define pb push_back

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

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

#define mp make_pair

#define ff first

#define ss second

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

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

#define INF 1e9

#define MOD 1000000007

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

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

#ifndef ONLINE_JUDGE

    #include "Jatt_don't_Care.h"

#else

    #define see(...) 42

#endif

void solve() {

ll n,x,y;

cin>>n>>x>>y;

x--,y--;

vll ans(n,0);

for1(i,0,n){

    if(i%2==1){

        ans[i]=1;

    }

}

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

    ans[x]=2;

}

for1(i,0,n){

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

}

cout<<"\n";

}

signed main() {

   Code_by_Millenialkiid

   ll t;

    cin >> t;

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

        #ifndef ONLINE_JUDGE

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

        #endif

       solve();

    }

    return 0;

}

Answer: 1


// || =================================================================== ||

// ||                                                                     ||

// ||                   Reach Expert by May 2025                          ||

// ||                                                                     ||

// || =================================================================== ||

#include <bits/stdc++.h>

#define int long long

#define endl "\n";

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

#define ONLINE_JUDGE

using namespace std;

long long mod_exp(long long base, long long exp, long long mod) {

    long long result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

void solve() {

    int n, x, y;

	cin >> n >> x >> y;

	vector<int> ans(n + 1);

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

		if(i & 1){

			ans[i] = 1;

		}else ans[i] = 0;

	}

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

		//nothing happens

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

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

		}

		cout << endl;

		return;

	}

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

		// // here also nothing happens

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

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

		}

		cout << endl;

		return;

	}

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

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

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

	}

	cout << endl;

}

signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    int t;

    cin >> t;

    while(t--)

        solve();

}

/*

void solve() {

    int n, k;

    cin >> n >> k;

    int r = n, l  =1;

	stack<pair<int,int>> st;

	st.push({l, r});

	int ans =0LL;

	while(st.size()){

		auto p = st.top();

		st.pop();

		int curL = p.first;

		int curR = p.second;

		if(curR - curL + 1 < k){

			// do nothing

		}else{

			int sz = curR - curL + 1;

			if(sz & 1){

				int m = (curL + curR) / 2LL;

				ans += m;

				cout << "{" << curL << " , " << curR << "} : " << m << endl;

				st.push({curL, m - 1LL});

				st.push({m + 1LL , curR});

			}else{

				int m = (curL + curR) / 2LL;

				st.push({curL, m});

				st.push({m + 1LL , curR});

			}

		}

	}

	cout << ans << endl;

}

 */

// || =================================================================== ||

// ||                                                                     ||

// ||                   Reach Expert by May 2025                          ||

// ||                                                                     ||

// || =================================================================== ||

#include <bits/stdc++.h>

#define int long long

#define endl "\n";

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

#define ONLINE_JUDGE

using namespace std;

long long mod_exp(long long base, long long exp, long long mod) {

    long long result = 1;

    while (exp > 0) {

        if (exp % 2 == 1) {

            result = (result * base) % mod;

        }

        base = (base * base) % mod;

        exp /= 2;

    }

    return result;

}

int m(set<int> arr){

	int st = 0;

	for(auto i : arr){

		if(i == st){

			// then do nothing

		}else{

			return st;

		}

		st++;

	}

	return st;

}

void solve() {

    int n, x, y;

	cin >> n >> x >> y;

	// vector<set<int>> f(n + 1);

	vector<int> ans(n + 1);

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

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

		else ans[i] = 1;

	}

	if((x + y) & 1){

		// i think it does not matter in case of even n is even only

		if(n % 2 == 0){

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

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

			}

			cout << endl;

		}else{

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

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

			}

			ans[n] = 2;

			cout << 2;

			cout << endl;

		}

	}else{

		// same number having people are friends

		// so one among them need to have 2 as ans[]

		if(n % 2 == 0){

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

				if(i == x){

					cout << 2 << " ";

					ans[i] = 2;

				}else {

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

				}

			}

			cout << endl;

		}else{

			ans[x] = 2;

			int idx = x - 1;

			if(idx == 0) idx = n;

			int cnt = 1;

			int val = 0;

			while(cnt < n){

				ans[idx] = val;

				val = !val;

				cnt++;

				idx--;

				if(idx == 0) idx = n;

			}

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

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

			}

			cout << endl;

		}

	}

	//validation

	vector<set<int>> f(n + 1);

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

		int nxt = i + 1;

		int prev = i - 1;

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

		if(prev == 0) prev = n;

		f[i].insert(nxt);

		f[i].insert(prev);

	}

	f[x].insert(y);

	f[y].insert(x);

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

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

	// cout << endl;

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

		set<int> friendsMx;

		// cout << "friends of " << i << " : " ;

		for(auto j : f[i]){

			// cout << j << " , " << ans[j] << " ; ";

			friendsMx.insert(ans[j]);

		}

		// cout << endl;

		// cout << "M value for " << i << " is " << m(friendsMx) << endl;

		// cout << "Ans value for " << i << " is " << ans[i] << endl;

		int m_val = m(friendsMx);

		if(m_val != ans[i]){

			cout << "wrong for " << i << endl;

		}

	}

}

signed main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    #ifndef ONLINE_JUDGE

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

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

    #endif

    int t;

    cin >> t;

    while(t--)

        solve();

}

/*

void solve() {

    int n, k;

    cin >> n >> k;

    int r = n, l  =1;

	stack<pair<int,int>> st;

	st.push({l, r});

	int ans =0LL;

	while(st.size()){

		auto p = st.top();

		st.pop();

		int curL = p.first;

		int curR = p.second;

		if(curR - curL + 1 < k){

			// do nothing

		}else{

			int sz = curR - curL + 1;

			if(sz & 1){

				int m = (curL + curR) / 2LL;

				ans += m;

				cout << "{" << curL << " , " << curR << "} : " << m << endl;

				st.push({curL, m - 1LL});

				st.push({m + 1LL , curR});

			}else{

				int m = (curL + curR) / 2LL;

				st.push({curL, m});

				st.push({m + 1LL , curR});

			}

		}

	}

	cout << ans << endl;

}

 */

Answer: 2


#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define int long long

const int inf = 0x7f7f7f7f;

const int mod = 1e9+7;

long long ksm(long long a,long long b){

	if(b==0) return 1;

	long long ans = 1;

	while(b>0){

		if(b & 1){

			ans= ans * a % mod;

		}

		a = a * a % mod;

		b>>=1;

	}

	return ans;

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	y--;x--;

	vector<int> ans(n);

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

	{

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

	}

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

	{

		ans[x] = 2;

	}

	for(auto t : ans)

		cout<<t<<" ";

	cout<<endl;

}

signed main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define int long long

const int inf = 0x7f7f7f7f;

const int mod = 1e9+7;

long long ksm(long long a,long long b){

	if(b==0) return 1;

	long long ans = 1;

	while(b>0){

		if(b & 1){

			ans= ans * a % mod;

		}

		a = a * a % mod;

		b>>=1;

	}

	return ans;

}

void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	vector<int> ans(n);

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

	{

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

	}

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

	{

		ans[x] = 2;

	}

	for(auto t : ans)

		cout<<t<<" ";

	cout<<endl;

}

signed main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	int t;

	cin>>t;

	while(t--){

		solve();

	}

	return 0;

}

Answer: 1


#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

#define int long long

#define PII std::pair<int,int>

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

using i64 = long long;

using i128 = __int128;

using u64 = unsigned long long;

constexpr int N = 2e6 + 5;

constexpr i64 INF = LLONG_MAX;

constexpr double eps = 1e-10;

constexpr int mod = 998244353;

constexpr int MOD = 1e9 + 7;

void Main()

{

    int n, x, y;

    cin >> n >> x >> y;

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

        int flag = 0, be = 1 + n % 2;

        cout << be << " \n"[n == 1];

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

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

            flag ^= 1;

        }

        return;

    }

    vector<int> ans(n + 1);

    int flag = 0;

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

        ans[i] = flag++;

        flag %= 3;

    }

    if (n % 3 == 1) {

        swap(ans[n], ans[n - 1]);

    }

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

        ans[y] = 3;

    }

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

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

    }

}

signed main()

{

    std::ios::sync_with_stdio(false);

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

    int T = 1;

    std::cin >> T;

    while (T--) {

        Main();

    }

    return 0;

}

#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

#define int long long

#define PII std::pair<int,int>

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

using i64 = long long;

using i128 = __int128;

using u64 = unsigned long long;

constexpr int N = 2e6 + 5;

constexpr i64 INF = LLONG_MAX;

constexpr double eps = 1e-10;

constexpr int mod = 998244353;

constexpr int MOD = 1e9 + 7;

void Main()

{

    int n, x, y;

    cin >> n >> x >> y;

    x--, y--;

    vector<int> ans(n);

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

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

    }

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

        ans[x] = 2;

    }

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

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

    }

}

signed main()

{

    std::ios::sync_with_stdio(false);

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

    int T = 1;

    std::cin >> T;

    while (T--) {

        Main();

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

void solve(){

   int n,x,y;

cin>>n>>x>>y;

int a[n];

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

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

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

        a[x]=2;

    }

}

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

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

    }

    cout<<endl;

    }

int main(){

    long long t;

	cin>>t;

	while(t--)

    {

       solve();

}

}

#include<bits/stdc++.h>

using namespace std;

void solve(){

   int n,x,y;

cin>>n>>x>>y;

 --x;--y;

int a[n];

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

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

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

        a[x]=2;

    }

}

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

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

    }

    cout<<endl;

    }

int main(){

    long long t;

	cin>>t;

	while(t--)

    {

       solve();

}

}

Answer: 2


def main():

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

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

        x -= 1

        y -=1

        ans = [0] * n

        for i in range(n):

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

        if n % 2 != 0  or (x - y) % 2 == 0:

            ans[x] = 2

        print(*ans)

if __name__ == "__main__":

    main()

def main():

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

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

        ans = [0] * n

        for i in range(n):

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

        if n % 2 != 0  or (x - y) % 2 == 0:

            ans[x] = 2

        print(*ans)

if __name__ == "__main__":

    main()

Answer: 1


#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

#define int long long

#define PII std::pair<int,int>

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

using i64 = long long;

using i128 = __int128;

using u64 = unsigned long long;

constexpr int N = 2e6 + 5;

constexpr i64 INF = LLONG_MAX;

constexpr double eps = 1e-10;

constexpr int mod = 998244353;

constexpr int MOD = 1e9 + 7;

void Main()

{

    int n, x, y;

    cin >> n >> x >> y;

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

        int flag = 0, be = 1 + n % 2;

        cout << be << " \n"[n == 1];

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

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

            flag ^= 1;

        }

        return;

    }

    vector<int> ans(n + 1);

    int flag = 0;

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

        ans[i] = flag;

        flag ^= 1;

    }

    if (n % 2 == 1) {

        ans[n] = 2;

    }

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

        ans[y] = 2;

    }

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

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

    }

}

signed main()

{

    std::ios::sync_with_stdio(false);

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

    int T = 1;

    std::cin >> T;

    while (T--) {

        Main();

    }

    return 0;

}

Answer: 2


#include <iostream>

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

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

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;

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

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

void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

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

    }

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

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

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

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

    int T = 1 ;

    cin >> T;

    while (T--){

        PLAY();

    }

    return 0;

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

long long n,m,t,k1,k2;

long long zs,zp,ys,yp;

string s1;

int main()

{

    cin>>t;

    for(int o=1;o<=t;++o){

        cin>>n>>k1>>k2;

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

            if(i%3==1)cout<<0<<" ";

            else if(i%3==2)cout<<1<<" ";

            else if(i%3==0)cout<<2<<" ";

        }

        cout<<endl;

    }

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long n,m,t,k1,k2;

long long zs,zp,ys,yp;

vector<int> a;

string s1;

int main()

{

    cin>>t;

    for(int o=1;o<=t;++o){

        cin>>n>>k1>>k2;

        a.clear();

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

            if(i%2==1)a.push_back(0);

            else a.push_back(1);

        }

        if(n%2==0){

            a.push_back(1);

            if(a[k1-1]==a[k2-1]){

                a[k1-1]=2;

            }

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

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

            }

        }

        else{

            a.push_back(2);

            if(a[k1-1]==a[k2-1]){

                if(k1!=1)a[k1-1]=2;

                else{

                    a[k1-1]=2;

                    a[n-1]=0;

                }

            }

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

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

            }

        }

        cout<<endl;

    }

    return 0;

}

Answer: 2


#include<bits/stdc++.h>

using namespace std;

#define int long long

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

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

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

        if(y==n&&a[1]==2) a[y]=2,a[1]=0;

        else  a[y]=2;

    }

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

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

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int t = 1;

    cin >> t;

    while (t--) {

        solve();

    }

}

#include<bits/stdc++.h>

using namespace std;

#define int long long

void solve() {

    int n,x,y;

    cin>>n>>x>>y;

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

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

           if(i%2){

               a[i]=0;

           }else{

               a[i]=1;

           }

    }

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

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

         a[y]=2;

    }

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

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

    }

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int t = 1;

    cin >> t;

    while (t--) {

        solve();

    }

}

Answer: 1


#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

#define ff first

#define ss second

#define pii pair<int,int>

#define vi vector<int>

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

void solve()

{

    int n,x,y;

    cin >> n>>x>>y;

    vi v(n);

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

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

        if(i&1)v[i]=0;

        else v[i]=1;

    }

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

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

        v[y-1]=2;

    }

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

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

    }

    cout<<endl;

}

signed main()

{

    int tcs;

    cin >> tcs;

    while (tcs--)

    {

        solve();

    }

}

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

#define ff first

#define ss second

#define pii pair<int,int>

#define vi vector<int>

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

void solve()

{

    int n,x,y;

    cin >> n>>x>>y;

    vi v(n);

    x--,y--;

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

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

    }

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

        v[x] = 2;

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

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

    }

    cout<<endl;

}

signed main()

{

    int tcs;

    cin >> tcs;

    while (tcs--)

    {

        solve();

    }

}

Answer: 2


#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


Answer: 1