import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class PD implements Runnable {
	private BufferedReader rd;
	private StringTokenizer tok = null;

	static class Node {
		public final ArrayList<Integer> childs = new ArrayList<Integer>();
		public int parent = Integer.MIN_VALUE;
	}

	private int n;
	private int r1;
	private int r2;
	private Node[] nodes;

	public static void main(String[] args) {
		new Thread(new PD()).start();
	}

	@Override
	public void run() {
		try {
			solve();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	private void solve() throws IOException {
		rd = new BufferedReader(new InputStreamReader(System.in));

		n = nextInt();
		r1 = nextInt() - 1;
		r2 = nextInt() - 1;

		nodes = new Node[n];
		for (int i = 0; i < n; ++i) {
			nodes[i] = new Node();
		}

		for (int i = 0; i < n; ++i) {
			if (i != r1) {
				int parent = nextInt() - 1;
				nodes[parent].childs.add(i);
				nodes[i].childs.add(parent);
			}
		}

		nodes[r2].parent = Integer.MIN_VALUE;
		rec(r2);

		PrintWriter wr = new PrintWriter(System.out);

		boolean first = true;
		for (int i = 0; i < n; ++i) {
			int parent = nodes[i].parent;
			if (parent != Integer.MIN_VALUE) {
				if (first) {
					wr.print(parent + 1);
					first = false;
				} else {
					wr.print(" ");
					wr.print(parent + 1);
				}
			}
		}

		wr.close();

		rd.close();
	}

	private void rec(int index) {
		Node node = nodes[index];
		for (int childIndex : node.childs) {
			Node childNode = nodes[childIndex];
			if (childIndex != node.parent) {
				childNode.parent = index;
				rec(childIndex);
			}
		}
	}

	private int nextInt() throws IOException {
		while (true) {
			if ((tok != null) && (tok.hasMoreTokens())) {
				break;
			}
			tok = new StringTokenizer(rd.readLine());
		}
		return Integer.parseInt(tok.nextToken());
	}
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class RoadMap {
    public static Node [] a;
    public static int [] res;
    public static int v2;
    public static int n;

    public static void main(String [] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int v1 = in.nextInt();
        v2 = in.nextInt();

        a = new Node[n+1];
        res = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = new Node(i);

        for (int i = 1; i <= n; i++){
            if(i == v1) continue;
            int t = in.nextInt();
            a[i].add(t);
            a[t].add(i);
        }

        res[v2] = -1;
        rec(v2);

        for (int i = 1; i <= n; i++)
            System.out.print(res[i]==-1?"":res[i]+" ");
    }

    public static class Node{
        int x;
        ArrayList<Integer> list;

        public Node(int x){
            this.x = x;
            list = new ArrayList<Integer>();
        }

        public void add(int x){
            list.add(x);
        }
    }

    public static void rec(int x){

        for(int i = 0; i < a[x].list.size(); i++)
            if(res[a[x].list.get(i)]!=x && res[a[x].list.get(i)]==0){
                res[a[x].list.get(i)] = x;
                rec(a[x].list.get(i));
            }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

	private int n;
	ArrayList<Integer>[] adj;
	private int r1;
	private int r2;
	private int[] ans;
	private boolean[] seen;

	@SuppressWarnings("unchecked")
	void solve() throws IOException {
		n = nextInt();
		r1 = nextInt();
		r2 = nextInt();

		adj = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
			adj[i] = new ArrayList<Integer>();
		}

		for (int i = 1; i <= n; i++) {
			if (i == r1)
				continue;
			int pi = nextInt();
			adj[i].add(pi);
			adj[pi].add(i);
		}

		ans = new int[n + 1];
		seen = new boolean[n + 1];
		dfs(r2);

		for (int i = 1; i <= n; i++) {
			if (i == r2)
				continue;
			out.print(ans[i] + " ");
		}
		out.println();
	}

	private void dfs(int u) {
		seen[u] = true;
		for (int v : adj[u]) {
			if (!seen[v]) {
				ans[v] = u;
				dfs(v);
			}
		}
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	Main() throws IOException {
		// Locale.setDefault(Locale.ENGLISH);
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		eat("");
		solve();
		in.close();
		out.close();
	}

	private void eat(String str) {
		st = new StringTokenizer(str);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String _token() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int _int() throws IOException {
        return Integer.parseInt(_token());
    }

    long _long() throws IOException {
        return Long.parseLong(_token());
    }

    double _double() throws IOException {
        return Double.parseDouble(_token());
    }

    void dbg(Object o) {
        System.out.println(o);
    }

    void debug(Object... os) {
        System.err.println(deepToString(os));
    }

    int[] v, w;

    void run() throws IOException {
        Locale.setDefault(Locale.US);
        //String name = "a";
        //String name = "step";
        //in = new BufferedReader(new FileReader(name + ".in"));
        in = new BufferedReader(new InputStreamReader(System.in));
        //out = new PrintWriter(new File(name + ".out"));
        out = new PrintWriter(System.out);
        st = new StringTokenizer(" ");
        int n = _int(), r1 = _int(), r2 = _int();
        v = new int[n + 1];
        w = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            if (i == r1) {
                v[i] = -1;
            } else {
                v[i] = _int();
            }
            w[i] = v[i];
        }
        int cur = r2;
        w[r2] = -1;
        while (cur != r1) {
            w[v[cur]] = cur;
            cur = v[cur];
        }
        for (int i = 1; i <= n; i++) {
            if (w[i] == -1) continue;
            out.print(w[i] + " ");
        }
        out.close();
    }

    /*ArrayList <Integer> ans = new ArrayList();

    void dfs(int t) {
        if (mark[t]) return;
        mark[t] = true;
        ans.add(t+1);
        for (int i = 0; i < n; i++) {
            if (w[t][i] && (!mark[i])) {
                dfs(i);
                ans.add(t+1);
            }
        }
    }*/

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}


import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.*;

public class Main implements Runnable {
	BufferedReader in;
	PrintStream out;
	StringTokenizer st = new StringTokenizer("");
	static boolean local = false;

	public static void main(String [] args) throws Exception {
		if (args.length > 0) local = true;
		new Thread(new Main()).start();
	}

	void printExit(String s) {
		System.out.println(s);
		System.exit(0);
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = local ? new BufferedReader(new FileReader("input.txt")) : new BufferedReader(new InputStreamReader(System.in));
			out = local ? new PrintStream(new File("output.txt")) : new PrintStream(System.out);

			int n = nextInt(), r1 = nextInt() - 1, r2 = nextInt() - 1;

			int [] l = new int[n - 1], r = new int[n - 1], use = new int[n];
			int k = 0;
			for (int i = 0; i < n; i++) {
				if (i == r1) continue;
				int par = nextInt() - 1;
				l[k] = i;
				r[k] = par;
				k++;
				use[i]++;
				use[par]++;
			}

			int [][] g = new int[n][];
			for (int i = 0; i < n; i++)
				g[i] = new int[use[i]];
			for (int i = 0; i < n - 1; i++) {
				int u = l[i], v = r[i];
				g[u][--use[u]] = v;
				g[v][--use[v]] = u;
			}

			int [] q = new int[n];
			boolean [] used = new boolean[n];
			int [] par = new int[n];
			q[0] = r2;
			used[r2] = true;
			int ql = 0, qr = 1;

			while (ql < qr) {
				int u = q[ql++];
				for (int v: g[u]) {
					//System.out.println(v + " " + u);
					if (!used[v]) {
						par[v] = u;

						used[v] = true;
						q[qr++] = v;
					}
				}
			}

			for (int i = 0; i < n; i++) {
				if (i == r2) continue;
				out.print((par[i] + 1) + " ");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}

	 boolean seekForToken() {
 		try {
			while (!st.hasMoreTokens()) {
				String s = in.readLine();
				if (s == null) {
				 	return false;
				}
			 	st = new StringTokenizer(s);
			}
			return true;
		}
		catch (IOException e) {
		 	e.printStackTrace();
		 	return false;
		}
 	}

 	 int nextInt() {
		return Integer.parseInt(nextToken());
 	}

 	 long nextLong() {
		return Long.parseLong(nextToken());
 	}

 	 double nextDouble() {
		return Double.parseDouble(nextToken());
 	}

 	 BigInteger nextBigInteger() {
 	 	return new BigInteger(nextToken());
 	}

 	 String nextToken() {
 	 	seekForToken();
 	 	return st.nextToken();
 	}

}


import java.util.*;

public class D {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r1 = sc.nextInt();
		int r2 = sc.nextInt();
		V[] v = new V[n];
		for(int i=0; i<n; i++)
			v[i] = new V(i+1);
		for(int i=0; i<n; i++) {
			if(i == r1 -1) continue;
			int x = sc.nextInt() - 1;
			v[i].add(v[x]);
			v[x].add(v[i]);
		}
		Queue<V> Q = new LinkedList<V>();
		Q.add(v[r2-1]);
		v[r2-1].p = 0;
		while(!Q.isEmpty()) {
			V u = Q.poll();
			for(V w: u) {
				if(w.p >= 0) continue;
				w.p = u.id;
				Q.add(w);
			}
		}
		for(int i=0; i<n; i++) {
			if(v[i].p == 0) continue;
			System.out.print(v[i].p+" ");
		}
		System.out.println();
	}
	static class V extends ArrayList<V> {
		int p  = -1;
		int id;
		public V(int id) {
			this.id = id;
		}
	}
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.ArrayList;
import java.text.DecimalFormat;

public class Main {

	static ArrayList<Integer> l[];
	static int mark[]=new int [100000];
	static int ans[]=new int [100000];

	public static int min(int x,int y)
	{
		return x>y?y:x;
	}
	public static int max(int x,int y)
	{
		return x>y?x:y;
	}
    public static void cout(String s)
    {
        System.out.println(s);

    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {

        	int n=in.nextInt();
        	int r1=in.nextInt();
        	int r2=in.nextInt();
        	int i;
        	l=new ArrayList[100000];
        	for(i=1;i<=n;i++)
        		l[i]=new ArrayList<Integer>();

        	for(i=1;i<=n;i++)
        	{
        		if(i==r1)
        			continue;
        		int x=in.nextInt();
        		l[i].add(x);
        		l[x].add(i);

        	}

        	for(i=1;i<=n;i++)
        	{
        		mark[i]=0;
        		ans[i]=-1;
        	}

        	gao(r2);

        	for(i=1;i<=n;i++)
        	{
        		if(i==r2)
        			continue;
        		System.out.print(ans[i]+" ");
        	}

        }
    }

   public static void gao(int x)
    {
    	mark[x]=1;
    	int i;
    	for(i=0;i<l[x].size();i++)
    	{
    		int y=l[x].get(i);
    		if(mark[y]==0)
    		{
    			ans[y]=x;
    			gao(y);
    		}

    	}

    }

}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.util.ArrayList;
import java.text.DecimalFormat;

public class Main {

    static ArrayList<Integer> l[];
    static int mark[]=new int [100000];
    static int ans[]=new int [100000];

    public static int min(int x,int y)
    {
        return x>y?y:x;
    }
    public static int max(int x,int y)
    {
        return x>y?x:y;
    }
    public static void cout(String s)
    {
        System.out.println(s);

    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {

            int n=in.nextInt();
            int r1=in.nextInt();
            int r2=in.nextInt();
            int i;
            l=new ArrayList[1100];
            for(i=1;i<=n;i++)
                l[i]=new ArrayList<Integer>();

            for(i=1;i<=n;i++)
            {
                if(i==r1)
                    continue;
                int x=in.nextInt();
                l[i].add(x);
                l[x].add(i);

            }

            for(i=1;i<=n;i++)
            {
                mark[i]=0;
                ans[i]=-1;
            }

            gao(r2);

            for(i=1;i<=n;i++)
            {
                if(i==r2)
                    continue;
                System.out.print(ans[i]+" ");
            }

        }
    }

   public static void gao(int x)
    {
        mark[x]=1;
        int i;
        for(i=0;i<l[x].size();i++)
        {
            int y=l[x].get(i);
            if(mark[y]==0)
            {
                ans[y]=x;
                gao(y);
            }

        }

    }

}


import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt(),r1=s.nextInt(),r2=s.nextInt();
		int[]p=new int[n+1];
		p[r1]=r1;
		for(int i=1;i<=n;++i)
			if(i!=r1)
				p[i]=s.nextInt();
		for(int e=r2,pa=r2;pa!=r1;){
			p[0] = p[e];
			p[e] = pa;
			pa = e;
			e = p[0];
		}
		StringBuffer sb = new StringBuffer();
		for(int i=1;i<=n;++i){
			if(i!=r2){
				sb.append(p[i]);
				sb.append(" ");
			}
		}
		System.out.println(sb.toString().trim());
	}
}


import java.util.*;

public class D {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt(),r1=s.nextInt(),r2=s.nextInt();
		int[]p=new int[n+1];
		p[r1]=r1;
		for(int i=1;i<=n;++i){
			if(i!=r1){
				p[i]=s.nextInt();
			}
		}
		dfs(p, r2, r1);
		StringBuffer sb = new StringBuffer();
		for(int i=1;i<=n;++i){
			if(i!=r2){
				sb.append(p[i]);
				sb.append(" ");
			}
		}
		System.out.println(sb.toString().trim());
	}

	static void dfs(int[] p, int now, int r1){
		if(now == r1) return;
		int t = p[now];
		dfs(p, t, r1);
		p[t] = now;
	}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class TMP {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
				System.out));
		new TMP().run(br, bw);
		bw.flush();
	}

	void run(BufferedReader r, BufferedWriter w) throws Exception {
		String[] ss = r.readLine().split(" ");
		int k = new Integer(ss[1]);
		int c = 0;
		for(int n = new Integer(ss[0]);n-->0;){
			if(new Integer(r.readLine())%k==0){
				++c;
			}
		}
		w.append(c+"\n");
	}
}


import java.util.*;

public class D {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt(), r1 = s.nextInt(), r2 = s.nextInt();
		List<List<Integer>>list=new ArrayList<List<Integer>>();
		for(int i=0;i<=n;++i){
			list.add(new ArrayList<Integer>());
		}
		for (int i = 1; i <= n; ++i) {
			if (r1 != i) {
				int v=s.nextInt();
				list.get(i).add(v);
				list.get(v).add(i);
			}
		}
		int[]b=new int[n+1];
		b[r2]=r2;
		Queue<int[]>q=new LinkedList<int[]>();
		for(int i : list.get(r2)){
			q.add(new int[]{i,r2});
		}
		while(!q.isEmpty()){
			int[]v=q.poll();
			b[v[0]]=v[1];
			for(int i : list.get(v[0])){
				if(b[i]<1){
					q.add(new int[]{i,v[0]});
				}
			}
		}
		StringBuilder result = new StringBuilder();
		for(int i=1;i<=n;++i){
			if(i!=r2){
				result.append(b[i]+" ");
			}
		}
		System.out.println(result.toString().trim());
	}
}


import java.util.*;

public class cf34d {
	static int[] v;
	static ArrayList<Integer>[] adj;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		v = new int[n];
		int oldC = in.nextInt()-1;
		int newC = in.nextInt()-1;
		adj = new ArrayList[n];
		for(int i=0; i<n; i++)
			adj[i] = new ArrayList<Integer>();

		for(int i=0; i<n; i++) {
			if(i==oldC) continue;
			int r = in.nextInt()-1;
			adj[i].add(r);
			adj[r].add(i);
		}
		go(newC, -1);
		for(int i=0; i<n; i++)
			if(i != newC)
				System.out.print(v[i] + " ");
		System.out.println();
	}
	static void go(int pos, int parent) {
		v[pos] = parent+1;
		for(int x : adj[pos])
			if(x != parent)
				go(x, pos);
	}
}


import java.util.*;

public class D {
	int n,r1,r2;
	int[] p;
	int tmp;
	String ans="";
	void exe(){

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		r1 = sc.nextInt();
		r2 = sc.nextInt();
		p = new int [n];
		for(int i=0;i<n;i++){
			if(i != r1-1){
				p[i] = sc.nextInt();
			} else {
				p[i] = 0;
			}
		}
		tmp = r2;
		while (tmp!=r1){
			int t = p[tmp-1];
			p[t-1] = tmp;
			tmp = t;
		}
		p[r2-1] = 0;
		for(int i=0;i<n;i++){
			if(p[i]!=0){
				ans += p[i]+" ";
			}
		}
		System.out.println(ans.substring(0, ans.length()-1));
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new D().exe();
	}
}


import java.util.*;

public class D {
	int n,r1,r2;
	int[] p;
	int tmp,tmp2;
	String ans="";
	void exe(){

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		r1 = sc.nextInt();
		r2 = sc.nextInt();
		p = new int [n];
		for(int i=0;i<n;i++){
			if(i != r1-1){
				p[i] = sc.nextInt();
			} else {
				p[i] = 0;
			}
		}
		tmp = r2;
		tmp2 = p[r2-1];
		while (tmp!=r1){
			int t = p[tmp2-1];
			p[tmp2-1] = tmp;
			tmp = tmp2;
			tmp2 = t;
		}
		p[r2-1] = 0;
		for(int i=0;i<n;i++){
			if(p[i]!=0){
				ans += p[i]+" ";
			}
		}
		System.out.println(ans.substring(0, ans.length()-1));
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new D().exe();
	}
}


import java.util.*;

public class D {
	int n,r1,r2;
	int[] p;
	int[] ans;
	int cur;

	void exe(){

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		r1 = sc.nextInt();
		r2 = sc.nextInt();
		p = new int[n];
		for(int i=0;i<n;i++){
			if(i!=r1-1){
				p[i] = sc.nextInt();
			} else {
				p[i] = 0;
			}
		}
		ans = (int[])p.clone();
		cur = r2;
		while (cur != r1){
			ans[p[cur-1]-1] = cur;
			cur = p[cur-1];
		}
		ans[r2-1]= 0;

		for(int i=0;i<n;i++){
			if(ans[i]!=0){
				System.out.print(""+ans[i]+" ");
			}
		}
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new D().exe();
	}
}


import java.util.*;

public class D {
	int n,r1,r2;
	int[] p;
	int tmp;
	String ans="";
	void exe(){

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		r1 = sc.nextInt();
		r2 = sc.nextInt();
		p = new int [n];
		for(int i=0;i<n;i++){
			if(i != r1-1){
				p[i] = sc.nextInt();
			} else {
				p[i] = 0;
			}
		}
		tmp = r2;
		while (tmp!=r1){
			int t = p[r2-1];
			p[t-1] = tmp;
			tmp = t;
		}
		p[r2-1] = 0;
		for(int i=0;i<n;i++){
			if(p[i]!=0){
				ans += p[i]+" ";
			}
		}
		System.out.println(ans.substring(0, ans.length()-1));
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new D().exe();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class RoadMap {

    void run() {
        try {
            BufferedReader bfd = new BufferedReader(new InputStreamReader(
                    System.in));
            StringTokenizer tk = new StringTokenizer(bfd.readLine());
            int n = Integer.parseInt(tk.nextToken()), i;
            int r1 = Integer.parseInt(tk.nextToken());
            int r2 = Integer.parseInt(tk.nextToken());
            tk = new StringTokenizer(bfd.readLine());
            @SuppressWarnings("unchecked")
            ArrayList<Integer>[] adj = new ArrayList[n+2];
            for(i=0; i<adj.length; ++i) adj[i] = new ArrayList<Integer>();
            for(i=1; i<n; ++i) {
                int x = Integer.parseInt(tk.nextToken());
                if(i<r1) {
                    adj[i].add(x);
                    adj[x].add(i);
                } else {
                    adj[i+1].add(x);
                    adj[x].add(i+1);
                }
            }
            int par[] = new int[n+2];
            Arrays.fill(par, -1);
            Queue<Integer> q = new LinkedList<Integer>();
            q.add(r2);
            par[r2] = 0;
            while(!q.isEmpty()) {
                int frnt = q.poll();
                for(i=0; i<adj[frnt].size(); ++i) {
                    if(par[adj[frnt].get(i)]==-1) {
                        q.add(adj[frnt].get(i));
                        par[adj[frnt].get(i)] = frnt;
                    }
                }
            }
            ArrayList<Integer> res = new ArrayList<Integer>();
            for(int num: par) if(num>0) res.add(num);
            for(i = 0; i<res.size()-1; ++i)
                System.out.print(res.get(i)+ " ");
            System.out.println(res.get(i));
        } catch (Exception e) {

        }
    }
    public static void main(String[] args) {
        new RoadMap().run();
    }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Capital {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new BufferedWriter(
				new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(in.readLine());
		int n = Integer.parseInt(st.nextToken()), c1 = Integer.parseInt(st
				.nextToken()), c2 = Integer.parseInt(st.nextToken());
		int cnt = 1;
		int[] a = new int[n + 1];
		st = new StringTokenizer(in.readLine());
		while (st.hasMoreTokens()) {
			if (cnt == c1)
				cnt++;
			a[cnt] = Integer.parseInt(st.nextToken());
			cnt++;
		}

		if (c2 != c1) {
			int temp = a[c2];
			int tmp = c2;
			while (temp != c1) {
				int t=a[temp];
				a[temp]=tmp;
				tmp=temp;
				temp=t;

			}
			a[temp] = tmp;
		}

		cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (i != c2 && cnt < n - 2) {
				out.print(a[i] + " ");
				cnt++;
			} else if (i != c2)
				out.println(a[i]);
		}
		out.println();

		out.close();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Stack;
import java.util.Vector;

public class Main {
	static boolean[][] graph;
	static int[] visited;
	static int[] ancestors;
	static int curMin;
	static int lastNode;
	static void dfs(int v, int d, int prev){
		visited[v]=1;
		ancestors[v]=prev+1;
		lastNode=v;
		for(int i=0; i<visited.length; i++){
			if (graph[v][i] && visited[i]==0) {
				dfs(i,d+1,v);
			}
		}
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		//BufferedReader in = new BufferedReader(new FileReader("input.txt"));
		//PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
		String[] input=in.readLine().split(" ");
		int n=Integer.parseInt(input[0]);
		int r1=Integer.parseInt(input[1]);
		int r2=Integer.parseInt(input[2]);
		graph=new boolean[n][n];
		visited=new int[n];
		ancestors=new int[n];
		String[] inp=in.readLine().split(" ");
		int plus=0;
		for(int i=0; i<n-1; i++){
			if(i+1>=r1) plus=1;
			else plus=0;
			int cur=Integer.parseInt(inp[i])-1;
			graph[i+plus][cur]=true;
			graph[cur][i+plus]=true;
		}
		dfs(r2-1,0,-1);
		for(int i=0; i<n-1; i++){
			if(i+1>=r2) plus=1;
			else plus=0;
			out.print(ancestors[i+plus]+" ");
		}
		out.close();
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int intl;
typedef unsigned long long intu;

#define int           long long // change here
#define sfi(x)        scanf("%lld", &x) // change here

#define sfi2(x, y)    sfi(x) , sfi(y)
#define sfi3(x, y, z) sfi(x) , sfi(y) , sfi(z)
#define sfc(x)        scanf(" %c", &x)
#define sfs(x)        scanf(" %s", x)
#define sfsn(x)       scanf(" %[^\n]s", x)

#define pfi(x)        printf("%lld", (intl)x)
#define pfis(x)       printf("%lld", (intl)x), printf(" ")
#define pfin(x)       printf("%lld", (intl)x), printf("\n")
#define pfs(x)        printf("%s", x)
#define pfnl          printf("\n")
#define pfsp          printf(" ")
#define endl          '\n'
#define sp            ' '

#define watch(x)      cout<<"::debug::   "<< #x <<" : "<<x<<endl
#define watchi(i, x)  cout<<"::debug::   "<< #x <<"-> ["<<i<<"]"<<" : "<<x<<endl

#define INPUT         freopen("input.txt","r",stdin);
#define OUTPUT        freopen("output.txt","w",stdout);
#define FastRead      ios::sync_with_stdio(false), cin.tie(0);

#define FOR(i, begin, end)  for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define repit(it, x)        for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#define perit(it, x)        for(__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); ++it)
#define rep(i, begin, end)  for(int i = (begin), ed = (end); i < (ed); ++i)
#define per(i, end, begin)  for(int i = (end)-1, bg = (begin); i >= (bg); --i)

#define setvalue(a, v)  for(int i = 0, sz = (sizeof(a)/sizeof(*a)); i<sz; i++){ a[i] = v; }
#define ZERO(a)       memset(a, 0, sizeof(a))
#define MINUS(a)      memset(a, 0xff, sizeof(a))

#define all(a)        a.begin(), a.end()
#define min3(x, y, z) min(x,min(y,z))
#define max3(x, y, z) max(x,max(y,z))
#define PI            2*acos(0)
#define INF           1000000007
#define debug         if( 0 )

const int mxn = 200010;

set<int> st;
int arr[mxn], idx[mxn];

void solve(int tc)
{
    st.clear();
    int n; sfi(n);

    for(int i=1; i<=n; i++) sfi(arr[i]), idx[arr[i]] = i;

    st.insert(1);
    pfi(1);

    int l = idx[1], r = idx[1];
    for(int i=2; i<=n; i++){
        if(idx[i]<l){
            for(int j=l-1; j>=idx[i]; j--) st.insert(arr[j]);
            l = idx[i];
        }
        else if(idx[i]>r){
            for(int j=l+1; j<=idx[i]; j++) st.insert(arr[j]);
            r = idx[i];
        }

        if(st.size() == i && *st.rbegin() == i) pfi(1);
        else pfi(0);
    }

    puts("");
}

int32_t main()
{
    //INPUT //OUTPUT
    //FastRead

    //solve(1);
    int tc; cin>>tc; rep(t, 1, tc+1) solve(t);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int intl;
typedef unsigned long long intu;

#define int           long long // change here
#define sfi(x)        scanf("%lld", &x) // change here

#define sfi2(x, y)    sfi(x) , sfi(y)
#define sfi3(x, y, z) sfi(x) , sfi(y) , sfi(z)
#define sfc(x)        scanf(" %c", &x)
#define sfs(x)        scanf(" %s", x)
#define sfsn(x)       scanf(" %[^\n]s", x)

#define pfi(x)        printf("%lld", (intl)x)
#define pfis(x)       printf("%lld", (intl)x), printf(" ")
#define pfin(x)       printf("%lld", (intl)x), printf("\n")
#define pfs(x)        printf("%s", x)
#define pfnl          printf("\n")
#define pfsp          printf(" ")
#define endl          '\n'
#define sp            ' '

#define watch(x)      cout<<"::debug::   "<< #x <<" : "<<x<<endl
#define watchi(i, x)  cout<<"::debug::   "<< #x <<"-> ["<<i<<"]"<<" : "<<x<<endl

#define INPUT         freopen("input.txt","r",stdin);
#define OUTPUT        freopen("output.txt","w",stdout);
#define FastRead      ios::sync_with_stdio(false), cin.tie(0);

#define FOR(i, begin, end)  for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define repit(it, x)        for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
#define perit(it, x)        for(__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); ++it)
#define rep(i, begin, end)  for(int i = (begin), ed = (end); i < (ed); ++i)
#define per(i, end, begin)  for(int i = (end)-1, bg = (begin); i >= (bg); --i)

#define setvalue(a, v)  for(int i = 0, sz = (sizeof(a)/sizeof(*a)); i<sz; i++){ a[i] = v; }
#define ZERO(a)       memset(a, 0, sizeof(a))
#define MINUS(a)      memset(a, 0xff, sizeof(a))

#define all(a)        a.begin(), a.end()
#define min3(x, y, z) min(x,min(y,z))
#define max3(x, y, z) max(x,max(y,z))
#define PI            2*acos(0)
#define INF           1000000007
#define debug         if( 0 )

const int mxn = 100010;

void solve(int tc)
{
    int n; sfi(n);
    int arr[n+1], idx[n+1];

    for(int i=1; i<=n; i++) sfi(arr[i]), idx[arr[i]] = i;

    set<int> st;
    st.insert(1);
    pfi(1);

    int l = idx[1], r = idx[1];
    for(int i=2; i<=n; i++){
        if(idx[i]<l){
            for(int j=l-1; j>=idx[i]; j--) st.insert(arr[j]);
            l = idx[i];
        }
        else if(idx[i]>r){
            for(int j=r+1; j<=idx[i]; j++) st.insert(arr[j]);
            r = idx[i];
        }

        if(st.size() == i && *st.rbegin() == i) pfi(1);
        else pfi(0);
    }

    puts("");
}

int32_t main()
{
    //INPUT //OUTPUT
    //FastRead

    //solve(1);
    int tc; cin>>tc; rep(t, 1, tc+1) solve(t);

    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;

        cin>>n;
        int arr[n];
        int pos_min;
        int pos_max;
        arr[0]=0;
        for(int i=1;i<=n;i++)
        {   int x;
            cin>> x;
            arr[x]=i;

        }
         cout<<1;
         pos_max=arr[1];
         pos_min=arr[1];
        for(int i=2;i<=n;i++)
        {
            pos_max=max(pos_max,arr[i]);
            pos_min=min(pos_min,arr[i]);
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;

        cin>>n;
        int arr[n];
        forn(i,n)
        {
            cin>>arr[i];
        }
        int pos_min=1000000000;
        int pos_max=-1;
        for(int i=1;i<=n;i++)
        {
            forn(j,n)
                {
                    if(arr[j]==i)
                    {
                        pos_max=max(pos_max,j);
                        pos_min=min(pos_min,j);
                        break;
                    }
                }
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;

        cin>>n;
        int arr[n];
        int pos_min;
        int pos_max;
        forn(i,n)
        {
            cin>>arr[i];
            if(arr[i]==1)
            {
                pos_min=pos_max=i;
            }
        }
         cout<<1;
        for(int i=2;i<=n;i++)
        {
            int dlag=0;
            for(int j=0;j<pos_min;j++)
                {
                    if(arr[j]==i)
                    {
                        pos_max=max(pos_max,j);
                        pos_min=min(pos_min,j);
                        dlag=1;
                        break;
                    }
                }
            if(!dlag){
            for(int j=pos_max+1;j<n;j++)
                {
                    if(arr[j]==i)
                    {
                        pos_max=max(pos_max,j);
                        pos_min=min(pos_min,j);
                        break;
                    }
                }}
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;

        cin>>n;
        int arr[n];
        int pos_min;
        int pos_max;
        forn(i,n)
        {   int x;
            cin>> x;
            arr[x-1]=i;

        }
         cout<<1;
         pos_max=arr[0];
        for(int i=1;i<n;i++)
        {
            pos_max=max(pos_max,arr[i]);
            pos_min=min(pos_min,arr[i]);
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;
        int arr[n];
        cin>>n;
        forn(i,n)
        {
            cin>>arr[i];
        }
        int pos_min=1000000000;
        int pos_max=-1;
        for(int i=1;i<=n;i++)
        {
            forn(j,n)
                {
                    if(arr[j]==i)
                    {
                        pos_max=max(pos_max,j);
                        pos_min=min(pos_min,j);
                        break;
                    }
                }
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
int main()
{
    int tt;
    cin>>tt;
    while(tt--)
    {
        int n;

        cin>>n;
        int arr[n];
        forn(i,n)
        {
            cin>>arr[i];
        }
        int pos_min=1000000000;
        int pos_max=-1;
        for(int i=1;i<=n;i++)
        {
            forn(j,n)
                {
                    if(arr[j]==i)
                    {
                        pos_max=max(pos_max,j);
                        pos_min=min(pos_min,j);

                    }
                }
            if((pos_max-pos_min+1)==i)
            {
                cout<<1;
            }else{cout<<0;}
        }
        cout<<endl;
    }
}


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

int main(){
    int t,n ;
    scanf("%d",&t) ;
    vector<int> v ;
    vector<int> pos ;
    string ch ;
    int mi,ma ,k;
    for(int i=0 ;i<t ;i++){
        scanf("%d",&n);
        v.clear();
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v.push_back(k);
            pos.push_back(k);
        }
        for(int j=0 ; j<n ; j++){
            pos[v[j]-1] = j ;
        }
        ch = '1' ;
        mi = ma =0 ;
        for(int j=1 ; j<n ; j++){
            if(pos[j]>pos[ma]){
                ma = j ;
            }else if(pos[j]<pos[mi]){
                mi = j ;
            }
            if(abs(pos[mi]-pos[ma])==j){
                ch = ch +'1' ;
            }else{
                ch = ch +'0' ;
            }
        }
        cout << ch <<endl ;

    }
    return 0 ;
}


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

int main(){
    int t ;
    scanf("%d",&t) ;

    int n,p ;
    int mi , ma ;
    string ch ;
    vector<int> v ;
    vector<string> res ;
    for(int k = 0 ; k<t ; k++){
        v.clear() ;
        scanf("%d" , &n) ;
        for(int i=0 ; i<n ;i++){
            scanf("%d",&p) ;
            v.push_back(p) ;
        }
        ch = "" ;
        for(int i=1 ; i<=n ; i++){

            mi = 0;
            ma = 0 ;
            for(int j = 0 ; j<n ; j++){
              if(v[j]<= i){
                ma = j ;
              }
              if(v[n-j-1]<= i){
                mi = n-j-1 ;
              }
            }
            if(ma - mi+1 == i){
                ch = ch + "1" ;
            }else{
                ch = ch + "0" ;
            }
        }

        //cout << ch << "  fjhgfdsdfggfd" << endl ;
        res.push_back(ch) ;

    }
    for(int k = 0 ; k<t ; k++){
        cout << res[k] << endl ;
    }
    return 0 ;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200001] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%d",&n) ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v[k-1] = j ;
        }

        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch <<"\n" ;

    }

    return 0 ;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v,v2 ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        cin >> n ;
        v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            cin >> k ;
            v.pb(k) ;
            v2.pb(k) ;
        }
        for(int j=0 ; j<n ; j++){
            v[v2[j]-1] = j ;
        }
        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch << endl ;

    }

    return 0 ;
}


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

int main(){
    //ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200001] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%d",&n) ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v[k-1] = j ;
        }

        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch <<"\n" ;

    }

    return 0 ;
}


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

int main(){
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v,v2 ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%n" ,n) ;
        v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%n" ,k) ;
            v.pb(k) ;
            v2.pb(k) ;
        }
        for(int j=0 ; j<n ; j++){
            v[v2[j]-1] = j ;
        }
        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch << endl ;

    }

    return 0 ;
}


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

int main(){
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v,v2 ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        cin >> n ;
        v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            cin >> k ;
            v.pb(k) ;
            v2.pb(k) ;
        }
        for(int j=0 ; j<n ; j++){
            v[v2[j]-1] = j ;
        }
        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch << endl ;

    }

    return 0 ;
}


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

int main(){
    //ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200003] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%d",&n) ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v[k-1] = j ;
        }

        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch <<"\n" ;

    }

    return 0 ;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200003] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%d",&n) ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v[k-1] = j ;
        }

        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch <<"\n" ;

    }

    return 0 ;
}


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

int main(){
    //ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200003] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        scanf("%d",&n) ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v[k-1] = j ;
        }

        cout << '1' ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            if((pma - pmi  )== j) cout << '1' ;
            else cout <<'0' ;

        }
        cout  <<"\n" ;

    }

    return 0 ;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ,t,k,pma,pmi;
    bool test ;
    string ch ;
    vector<int> v2;
    int v[200001] ;
    cin >> t;
    for(int i =0 ; i<t ; i++){
        cin >> n ;
       // v.clear() ;
        v2.clear() ;
        for(int j=0 ; j<n ; j++){
            cin >> k ;
            v[k-1] = j ;
        }

        ch = "1" ;
        pma = v[0] ;
        pmi = v[0] ;
        for(int j=1 ; j<n ; j++){
            pma = max(pma , v[j]) ;
            pmi = min(pmi ,v[j]) ;

            ch = ((pma - pmi  )== j ) ? ch + "1" : ch + "0" ;

        }
        cout << ch << endl ;

    }

    return 0 ;
}


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

int main(){
    int t,n,k ;
    scanf("%d",&t) ;
    vector<int> v ;
    vector<int> pos ;
    string ch ;
    int mi,ma ;
    for(int i=0 ;i<t ;i++){
        scanf("%d",&n);
        v.clear();
        for(int j=0 ; j<n ; j++){
            scanf("%d",&k) ;
            v.push_back(k);
            pos.push_back(k);
        }
        for(int j=0 ; j<n ; j++){
            pos[v[j]-1] = j ;
        }
        ch = '1' ;
        mi = ma =0 ;
        for(int j=1 ; j<n ; j++){
            if(pos[j]>pos[ma]){
                ma = j ;
            }else if(pos[j]<pos[mi]){
                mi = j ;
            }
            if(abs(pos[mi]-pos[ma])==j){
                ch = ch +'1' ;
            }else{
                ch = ch +'0' ;
            }
        }
        cout << ch <<endl ;

    }
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="";
      vector<int> r(n),b(n+1,0);
      fr(i,0,n){cin>>r[i];b[r[i]]=i;}
      if(n==1){cout<<g<<endl;continue;}
      int mai=b[1],mii=b[1];
      fr(i,1,n+1)
      {
          mai=max(mai,b[i]);mii=min(mii,b[i]);
          if(mai-mii==i-1){g+="1";}
          else{g+="0";}
      }
      cout<<g<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="1";
      vector<vector<bool>> f(n+1,vector<bool> (n,false));
      vector<int> r(n);
      fr(i,0,n){cin>>r[i];}if(n==1){cout<<g<<endl;continue;}
      fr(i,0,n)
      {
        fr(j,r[i],n+1){f[i][j]=true;}
      }
      fr(i,2,n)
      {int count=0;bool q=false;
        fr(j,0,n)
        {
          if(f[j][i]==true)
           {q=true;count++;if(count==i){g+="1";break;}}
           else if(q==true && f[j][i]==false)
           {g+="0";break;}
        }
      }
      g+="1";cout<<g<<endl;g="";f.clear();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="";
      vector<int> r(n),b(n+1,0);
      fr(i,0,n){cin>>r[i];b[r[i]]=i;}
      int mai=b[1],mii=b[1];
      fr(i,1,n+1)
      {
          mai=max(mai,b[i]);mii=min(mii,b[i]);
          if(mai-mii==i-1){g+="1";}
          else{g+="0";}
      }
      cout<<g<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="1";
      vector<vector<bool>> f(n+1,vector<bool> (n,false));
      vector<int> r(n);
      fr(i,0,n){cin>>r[i];}
      fr(i,0,n)
      {
        fr(j,r[i],n+1){f[i][j]=true;}
      }
      fr(i,2,n)
      {int count=0;q=false;
        fr(j,0,n)
        {
          if(f[j][i]==true)
           {q=true;count++;if(count==i){g+="1";break;}}
           else if(q==true && f[j][i]==false)
           {g+="0";break;}
        }
      }
      g+="1";cout<<g<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="1";
      vector<vector<bool>> f(n+1,vector<bool> (n,false));
      vector<int> r(n);
      fr(i,0,n){cin>>r[i];}
      fr(i,0,n)
      {
        fr(j,r[i],n+1){f[i][j]=true;}
      }
      fr(i,2,n)
      {int count=0;bool q=false;
        fr(j,0,n)
        {
          if(f[j][i]==true)
           {q=true;count++;if(count==i){g+="1";break;}}
           else if(q==true && f[j][i]==false)
           {g+="0";break;}
        }
      }
      g+="1";cout<<g<<endl;g="";f.clear();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
int main()
{
    int q;cin>>q;
    while(q--)
    {
      int n;cin>>n;string g="1";if(n==1){cout<<g<<endl;continue;}
      vector<vector<bool>> f(n+1,vector<bool> (n,false));
      vector<int> r(n);
      fr(i,0,n){cin>>r[i];}
      fr(i,0,n)
      {
        fr(j,r[i],n+1){f[i][j]=true;}
      }
      fr(i,2,n)
      {int count=0;bool q=false;
        fr(j,0,n)
        {
          if(f[j][i]==true)
           {q=true;count++;if(count==i){g+="1";break;}}
           else if(q==true && f[j][i]==false)
           {g+="0";break;}
        }
      }
      g+="1";cout<<g<<endl;g="";f.clear();
    }
}


#include<bits/stdc++.h>
#define test_cases()          int t; cin>>t; while(t--)
using namespace std;

int main(){

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

  test_cases(){
    int n;
    cin>>n;
    int dp[n+1];
    int temp;
    for (int i = 0; i < n; ++i)
    {
      cin>>temp;
      dp[temp]=i;
    }
    int maxi=dp[1];
    int mini=dp[1];
    string s="";
    for (int i = 1; i <=n; ++i)
    {
      maxi=max(dp[i],maxi);
      mini=min(dp[i],mini);

      if(maxi-mini+1==i)
        s+="1";
      else
        s+="0";

    }
      cout<<s<<"\n";

  }
  return 0;

}


#include<bits/stdc++.h>

#define test_cases()          int t; cin>>t; while(t--)

using namespace std;

int main(){

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

  test_cases(){
    int n;
    cin>>n;
    int dp[n+1];
    int temp;
    for (int i = 0; i < n; ++i)
    {
      cin>>temp;
      dp[temp]=i;
    }
    int maxi=dp[1];
    int mini=dp[1];
    string s="";
    for (int i = 1; i <=n; ++i)
    {
      maxi=max(dp[i],maxi);
      mini=min(dp[i],mini);

      if(maxi-mini+1==i)
        s+="1";
      else
        s+="0";

    }
      cout<<s<<endl;

  }
  return 0;

}


#include<bits/stdc++.h>
#define test_cases()          int t; cin>>t; while(t--)
using namespace std;

int main(){

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

  test_cases(){
    int n;
    cin>>n;
    int dp[n+1];
    int temp;
    for (int i = 0; i < n; ++i)
    {
      cin>>temp;
      dp[temp]=i;
    }
    int maxi=dp[1];
    int mini=dp[1];
    string s="";
    for (int i = 1; i <=n; ++i)
    {
      maxi=max(dp[i],maxi);
      mini=min(dp[i],mini);

      if(maxi-mini+1==i)
        s+="1";
      else
        s+="0";

    }
      cout<<s<<endl;

  }
  return 0;

}


#include<bits/stdc++.h>

#define test_cases()          int t; cin>>t; while(t--)

using namespace std;

int main(){

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

  test_cases(){
    int n;
    cin>>n;
    int dp[n+1];
    int temp;
    for (int i = 0; i < n; ++i)
    {
      cin>>temp;
      dp[temp]=i;
    }
    int maxi=dp[1];
    int mini=dp[1];
    string s="";
    for (int i = 1; i <=n; ++i)
    {
      maxi=max(dp[i],maxi);
      mini=min(dp[i],mini);

      if(maxi-mini+1==i)
        s=s+"1";
      else
        s=s+"0";

    }
      cout<<s<<endl;

  }
  return 0;

}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        char c='i';
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        for (int i=1;i<n-1;i++){
            for (int j=0;j<i;j++){
                for (int g=min(k[i],k[j]);g<max(k[i],k[j]);g++){
                    if (a[g]>i+1) {c='0';break;}
                }
                if (c=='0') {s+=c;c='i';break;}
                if (j==i-1) s+='1';
            }
        }
        s+='1';
        cout<<s<<endl;
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n,ml=0,mp=0;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        for (int i=1;i<n-1;i++){
            if (i<n/2)
            for (int j=0;j<i;j++){
                if (k[j]>k[i]) mp=max(mp,k[j]-k[i]);
                if (k[j]<k[i]) ml=max(ml,k[i]-k[j]);
                if (mp+ml>i) {s+='0';break;}
                if (j==i-1) s+='1';
            } else
            for (int j=i+1;j<n;j++){
                if (k[j]>k[i]) mp=max(mp,k[j]-k[i]);
                if (k[j]<k[i]) ml=max(ml,k[i]-k[j]);
                if (mp+ml<i) {s+='0';break;}
                if (j==n-1) s+='1';
            }
            mp=0;ml=0;
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        char c='i';
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        for (int i=1;i<n-1;i++){
            for (int j=0;j<i;j++){
                for (int g=min(k[i],k[j]);g<max(k[i],k[j]);g++){
                    if (a[g]>i+1) {c='0';break;}
                }
                if (c=='0') {s+=c;c='i';break;}
                if (j==i-1) s+='1';
            }
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n,ml=0,mp=0;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        char c='i';
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        for (int i=1;i<n-1;i++){
            for (int j=0;j<i;j++){
                if (k[j]>k[i]) mp=max(mp,k[j]-k[i]);
                if (k[j]<k[i]) ml=max(ml,k[i]-k[j]);
                if (mp+ml>i) c='0';
                if (c=='0') {s+=c;c='i';break;}
                if (j==i-1) s+='1';
            }
            mp=0;ml=0;
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n,ml=0,mp=0;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        for (int i=1;i<n-1;i++){
            mp=0;ml=0;
            if (i<n/2)
            for (int j=0;j<i;j++){
                if (k[j]>k[i]) mp=max(mp,k[j]-k[i]);
                if (k[j]<k[i]) ml=max(ml,k[i]-k[j]);
                if (mp+ml>i) {s+='0';break;}
                if (j==i-1) s+='1';
            } else{
            mp=100000;ml=100000;
            for (int j=i+1;j<n;j++){
                if (k[j]>k[i]) mp=min(mp,k[j]-k[i]-1);
                if (k[j]<k[i]) ml=min(ml,k[i]-k[j]-1);
                if (mp+ml+1<i) {s+='0';break;}
                if (j==n-1) {
                        if (mp==100000) mp=n-k[i]-1;
                        if (mp+ml<i) {s+='0';break;}
                        if (ml==100000) ml=k[i];
                        if (mp+ml<i) {s+='0';break;}
                        s+='1';
                }
            }
            }
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n,ml=0,mp=0;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        for (int i=1;i<n-1;i++){
            for (int j=0;j<i;j++){
                if (k[j]>k[i]) mp=max(mp,k[j]-k[i]);
                if (k[j]<k[i]) ml=max(ml,k[i]-k[j]);
                if (mp+ml>i) {s+='0';break;}
                if (j==i-1) s+='1';
            }
            mp=0;ml=0;
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t,n,ml=0,mp=0;
    cin>>t;
    string s;
    for (int h=0;h<t;h++){
        cin>>n;
        s="1";
        int a[n];
        vector<int> k(n,0);
        for (int i=0;i<n;i++) {cin>>a[i];k[a[i]-1]=i;}
        if (n==1) cout<<1<<endl; else {
        mp=k[0];ml=mp;
        for (int i=1;i<n-1;i++){
            if (k[i]>mp) mp=k[i]; else if (k[i]<ml) ml=k[i];
            if (mp-ml==i) s+='1'; else s+='0';
        }
        s+='1';
        cout<<s<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        t--;
        int n,x;
        vector <int> v;

        cin>>n;
        map <int,int> re;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
        }
        for(int i=0;i<n;i++)
        {   int count =0;
            int l=i,r=i,f=1;
            int lt=1,rt=1;
            while((l>0||r<(n-1))&&count<(v[i]-1))
            {
                l--;
                r++;
                if(l>=0){if(v[l]<v[i]&&lt!=0) count++;
                else if(lt==0&&v[l]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[l]>v[i])
                lt=0;}
                         if(r<=(n-1)){       if(v[r]<v[i]&&rt!=0) count++;
                else if(rt==0&&v[r]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[r]>v[i])
                rt=0;}

            }
            if(f!=0&&count==v[i]-1)
                re[v[i]]=1;

        }
        for(int i=1;i<=n;i++)
        cout<<re[i];
        cout<<endl;
    }

    return 0;

}


#include <iostream>
#include<vector>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        t--;
        int n,x;
        vector <int> v;

        cin>>n;
        int re[200001] = {-1};
        for(int i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
        }
        for(int i=0;i<n;i++)
        {   int count =0;
            int l=i,r=i,f=1;
            int lt=1,rt=1;
            while((l!=0||r!=(n-1))&&count<(v[i]-1))
            {
                if(l!=0) l--;
                if(r!=n-1) r++;
                if(v[l]<v[i]&&lt!=0) count++;
                else if(lt==0&&v[l]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[l]>v[i])
                lt=0;
                                if(v[r]<v[i]&&rt!=0) count++;
                else if(rt==0&&v[r]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[r]>v[i])
                rt=0;
            }
            if(f!=0&&count==v[i]-1)
                re[v[i]]=1;

        }
        for(int i=1;i<=n;i++)
        cout<<re[i];
        cout<<endl;
    }

    return 0;

}


#include <iostream>
#include<vector>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        t--;
        int n,x;
        vector <int> v;

        cin>>n;
        int re[200001] = {-1};
        for(int i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
        }
        for(int i=0;i<n;i++)
        {   int count =0;
            int l=i,r=i,f=1;
            int lt=1,rt=1;
            while((l>0||r<(n-1))&&count<(v[i]-1))
            {
                l--;
                r++;
                if(l>=0){if(v[l]<v[i]&&lt!=0) count++;
                else if(lt==0&&v[l]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[l]>v[i])
                lt=0;}
                         if(r<=(n-1)){       if(v[r]<v[i]&&rt!=0) count++;
                else if(rt==0&&v[r]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[r]>v[i])
                rt=0;}

            }
            if(f!=0&&count==v[i]-1)
                re[v[i]]=1;

        }
        for(int i=1;i<=n;i++)
        cout<<re[i];
        cout<<endl;
    }

    return 0;

}


#include <iostream>
#include<vector>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        t--;
        int n,x;
        vector <int> v;

        cin>>n;
        int re[200001] = {-1};
        for(int i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
        }
        for(int i=0;i<n;i++)
        {   int count =0;
            int l=i,r=i,f=1;
            int lt=1,rt=1;
            while((l!=0||r!=(n-1))&&count<(v[i]-1))
            {
                if(l!=0) l--;
                if(r!=n-1) r++;
                if(l!=-1){if(v[l]<v[i]&&lt!=0) count++;
                else if(lt==0&&v[l]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[l]>v[i])
                lt=0;}
                         if(r!=-1){       if(v[r]<v[i]&&rt!=0) count++;
                else if(rt==0&&v[r]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[r]>v[i])
                rt=0;}
                if(l==0)
                    l--;
                    if(r==0)
                    r--;
            }
            if(f!=0&&count==v[i]-1)
                re[v[i]]=1;

        }
        for(int i=1;i<=n;i++)
        cout<<re[i];
        cout<<endl;
    }

    return 0;

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define INF (int)1e9
#define fora(i,a,b) for(int i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
using namespace std;

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

    int t;
    cin>>t;
    while(t>0)
    {
        int n,x,l,r;
        vi vt;
        cin>>n;
        map<int,int> mm;
        fora(i,0,n)
        {
            cin>>x;
           // v.pb(x);
            mm[x]=i;
            if(x==1)
            {
                l=i;
                r=i;
            }
        }
        vt.pb(1);
        fora(i,2,n+1)
        {
            l=min(l,mm[i]);
            r=max(r,mm[i]);
            //cout<<"("<<l<<r<<")"<<endl;
            if(r-l==i-1)
            vt.pb(1);
            else
            vt.pb(0);

        }
        fora(i,0,vt.si)
        {
            cout<<vt[i];
        }
        cout<<endl;
        t--;
    }

    return 0;
}


#include <iostream>
#include<vector>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t>0)
    {
        t--;
        int n,x;
        vector <int> v;

        cin>>n;
        int re[200001] = {-1};
        for(int i=0;i<n;i++)
        {
            cin>>x;
            v.push_back(x);
        }
        for(int i=0;i<n;i++)
        {   int count =0;
            int l=i,r=i,f=1;
            int lt=1,rt=1;
            while((l!=0||r!=(n-1))&&count<(v[i]-1))
            {
                if(l!=0) l--;
                if(r!=n-1) r++;
                if(v[l]<v[i]&&lt!=0) count++;
                else if(lt==0&&v[l]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[l]>v[i])
                lt=0;
                                if(v[r]<v[i]&&rt!=0) count++;
                else if(rt==0&&v[r]<v[i])
                {re[v[i]]=0;
                f=0;
                break;}
                if(v[r]>v[i])
                rt=0;
            }
            if(f!=0&&count==v[i]-1)
                re[v[i]]=1;

        }
        for(int i=1;i<=n;i++)
        cout<<re[i];
    }

    return 0;

}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n,index; cin >> n;
		int a[n];
		for(int i=0;i<n;i++)
		{
		    cin >> a[i];
		    if(a[i]==1)
		    {
		        index=i;
		    }
		}
		string s="1";
		for(int si=2;si<=n;si++)
		{
		    int l=index-si+1,flag=0;
		    if(l<0)
		    {
		        l=0;
		    }
		    int r=index+si-1;
		    if(r>n-1)
		    {
		        r=n-si;
		    }
		    for(int i=l;i<=r;i++)
		    {
		        string str="";
		        for(int j=i;j<=i+si-1;j++)
		        {
		            str=str+to_string(a[j]);
		        }
		        sort(str.begin(),str.end());
		        if(str[0]=='1' && (str[str.size()-1]-'0')==si)
		        {
		            s=s+'1';
		            /*cout << i << " ";*/
		            flag=1;
		            break;
		        }
		    }
		    if(flag==0)
		    {
		        s=s+'0';
		    }
		    /*cout << s << endl;*/
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n+1];
		for(int i=0;i<n;i++)
		{
		    int x; cin >> x;
		    pos[x-1]=i;
		}
		int l=pos[0],r=pos[0];
		string s="1";
		for(int i=1;i<n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l==i)
		    {
		        s=s+'1';
		    }
		    else
		    {
		        s=s+'0';
		    }
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n+1];
		for(int i=1;i<=n;i++)
		{
		    int x; cin >> x;
		    pos[x]=i;
		}
		int l=pos[1],r=pos[1];
		string s="1";
		for(int i=2;i<=n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l+1==i)
		    {
		        s=s+'1';
		    }
		    else
		    {
		        s=s+'0';
		    }
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n+1];
		for(int i=1;i<=n;i++)
		{
		    int x; cin >> x;
		    pos[x]=i;
		}
		int l=pos[1],r=pos[1];
		string s="1";
		for(int i=2;i<=n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l+1==i)
		    {
		        s=s+to_string(1);
		    }
		    else
		    {
		        s=s+to_string(0);
		    }
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n];
		for(int i=0;i<n;i++)
		{
		    int x; cin >> x;
		    pos[x-1]=i;
		}
		int l=pos[0],r=pos[0];
		string s="1";
		for(int i=1;i<n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if((r-l)==i)
		    {
		        s=s+'1';
		    }
		    else
		    {
		        s=s+'0';
		    }
		}
		cout << s << endl;
	}
}


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string ans = "1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r - l == i)
            {
                ans += '1';
            }
            else
            {
                ans += '0';
            }
        }
        cout << ans << endl;;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string s1="1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r-l == i)
            {
                s1=s1+'1';
            }
            else
            {
                s1=s1+'0';
            }
        }
        cout << s1 << endl;
    }
    return 0;
}


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string ans = "1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r - l == i)
                ans += '1';
            else
                ans += '0';
        }
        cout << ans << endl;;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 239;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[M];
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        p[x - 1] = i;
    }
    int l = n;
    int r = 0;
    string ans = "";
    for (int i = 0; i < n; i++)
    {
        l = min(l, p[i]);
        r = max(r, p[i]);
        if (r - l == i)
            ans += '1';
        else
            ans += '0';
    }
    cout << ans << endl;;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string s="1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r-l == i)
            {
                s=s+'1';
            }
            else
            {
                s=s+'0';
            }
        }
        cout << s << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n];
		for(int i=0;i<n;i++)
		{
		    int x; cin >> x;
		    pos[x-1]=i;
		}
		int l=pos[0],r=pos[0];
		string s="1";
		for(int i=1;i<n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l==i)
		    {
		        s=s+'1';
		    }
		    else
		    {
		        s=s+'0';
		    }
		}
		cout << s << endl;
	}
}


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        p[x - 1] = i;
    }
    int l = n;
    int r = 0;
    string ans = "";
    for (int i = 0; i < n; i++)
    {
        l = min(l, p[i]);
        r = max(r, p[i]);
        if (r - l == i)
            ans += '1';
        else
            ans += '0';
    }
    cout << ans << endl;;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n];
		for(int i=0;i<n;i++)
		{
		    int x; cin >> x;
		    pos[x-1]=i;
		}
		int l=pos[0],r=pos[0];
		string s="1";
		for(int i=1;i<n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l==i)
		    {
		        s=s+'1';
		    }
		    else
		    {
		        s=s+'0';
		    }
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int M = 2e5 + 239;

int n, p[M], x;

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        p[x - 1] = i;
    }
    int l = n;
    int r = 0;
    string ans = "";
    for (int i = 0; i < n; i++)
    {
        l = min(l, p[i]);
        r = max(r, p[i]);
        if (r - l == i)
            ans += '1';
        else
            ans += '0';
    }
    cout << ans << "\n";
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string s="1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r-l == i)
            {
                s=s+'1';
            }
            else
            {
                s=s+'0';
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n+1];
		for(int i=1;i<=n;i++)
		{
		    int x; cin >> x;
		    pos[x]=i;
		}
		int l=pos[1],r=pos[1];
		string s="1";
		for(int i=2;i<=n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l+1==i)
		    {
		        s+='1';
		    }
		    else
		    {
		        s+='0';
		    }
		}
		cout << s << endl;
	}
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
	ll p;
	cin>>p;
	while(p--)
	{
		int n; cin >> n;
		int pos[n+1];
		for(int i=1;i<=n;i++)
		{
		    int x; cin >> x;
		    pos[x]=i;
		}
		int l=pos[1],r=pos[1];
		string s="1";
		for(int i=2;i<=n;i++)
		{
		    l=min(l,pos[i]);
		    r=max(r,pos[i]);
		    if(r-l+1==i)
		    {
		        s=s+"1";
		    }
		    else
		    {
		        s=s+"0";
		    }
		}
		cout << s << endl;
	}
}


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        p[x - 1] = i;
    }
    int l = p[0];
    int r = p[0];
    string ans = "1";
    for (int i = 1; i < n; i++)
    {
        l = min(l, p[i]);
        r = max(r, p[i]);
        if (r - l == i)
            ans += '1';
        else
            ans += '0';
    }
    cout << ans << endl;;
    }
    return 0;
}


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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n; cin >> n;
        int p[n];
        for (int i = 0; i < n; i++)
        {
            int x; cin >> x;
            p[x - 1] = i;
        }
        int l = p[0];
        int r = p[0];
        string ans = "1";
        for (int i = 1; i < n; i++)
        {
            l = min(l, p[i]);
            r = max(r, p[i]);
            if (r - l == i)
            {
                ans = ans + '1';
            }
            else
            {
                ans = ans + '0';
            }
        }
        cout << ans << endl;;
    }
    return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<double,double>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTUU tcT, class ...U
#define tcTU tcT, class U
#define tcTU3 tcTU, class C
#define tcTU4 tcTU3, class D

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using mpq = priority_queue<T, vector<T>, greater<T>>;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

tcT> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key */

#define ut uint64_t
struct fhash {
    static ut s(ut x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
	}
    size_t operator()(ut x) const {
        static const ut r = chrono::steady_clock::now().time_since_epoch().count();
        return s(x+r);
	}
};
#define z(n) static_cast<decay<decltype(n)>::type>(n);
#define cbit(n, b) (((n)>>(b))&1)
#define sbit(n, b) ((n)|(z(1)<<(b)))
#define rbit(n, b) ((n)&~(z(1)<<(b)))
#define fbit(n, b) ((n)^(z(1)<<(b)))

#define ts to_string
#define fe first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(v) ((int)(v).size())
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

tcTU> T fstTrue(T lo, T hi, U f) {
	while (lo < hi) {
		T mid = (lo+hi)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	while (lo < hi) {
		T mid = (lo+hi+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}

const int di[4]={-1, 0, 1, 0}, dj[4]={0, 1, 0, -1};
const int di8[8]={-1, -1, 0, 1, 1, 1, 0, -1}, dj8[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int MOD = 1e9+7; //const int MOD =998244353;
const ld PI = acos((ld)-1);

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll randint(ll a, ll b) { return uniform_int_distribution<ll>(a, b)(rng);}

bool pow2(int i){ return i&&(i&-i)==i;}
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

tcT> bool chmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
tcT> bool chmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

tcT> void remDup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)),end(v)); }

// TO_STRING
tcTU3> string ts(tuple<T,U,C> p);
tcTU4> string ts(tuple<T,U,C,D> p);
string ts(char c) { return string(1,c); }
string ts(bool b) {
    #ifdef __APPLE__
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
tcT> string ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
string ts(vb v) {
	string res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string ts(bitset<SZ> b) {
	string res = ""; F0R(i,sz(b)) res += char('0'+b[i]);
	return res; }
tcTU> string ts(pair<T,U> p);
tcT> string ts(T v) { // containers with begin(), end()
	#ifdef __APPLE__
		bool fst = 1; string res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; string res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;
	#endif
}
tcTU> string ts(pair<T,U> p) {
	#ifdef __APPLE__
		return "("+ts(p.fe)+", "+ts(p.se)+")";
	#else
		return ts(p.fe)+" "+ts(p.se);
	#endif
}
tcTU3> string ts(tuple<T,U,C> p) {
	#ifdef __APPLE__
	    return "("+ts(get<0>(p))+","+ts(get<1>(p))+","+ts(get<2>(p))+")";
	#else
	    return ts(get<0>(p))+" "+ts(get<1>(p))+" "+ts(get<2>(p));
	#endif
}
tcTU4> string ts(tuple<T,U,C,D> p) {
	#ifdef __APPLE__
	    return "("+ts(get<0>(p))+","+ts(get<1>(p))+","+ts(get<2>(p))+","+ts(get<3>(p))+")";
	#else
	    return ts(get<0>(p))+" "+ts(get<1>(p))+" "+ts(get<2>(p))+" "+ts(get<3>(p));
	#endif
}
//INPUT  void re(string& d){getline(cin,d) ;getline(cin,d); }

tcTU3> void re(tuple<T,U,C>& p);
tcTU4> void re(tuple<T,U,C,D>& p);
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);

tcT, size_t SZ> void re(AR<T,SZ>& a);
tcT> void re(T& x) { cin >> x; }
void re(double& d) { string t; re(t); d = stod(t); }
void re(ld& d) { string t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }
tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(array<T,SZ>& x) { trav(a,x) re(a); }
tcTU3> void re(tuple<T,U,C>& p){re(get<0>(p),get<1>(p),get<2>(p));}
tcTU4> void re(tuple<T,U,C,D>& p){re(get<0>(p),get<1>(p),get<2>(p),get<3>(p));}
// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef __APPLE__ // chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

/*
template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint() { v = 0; }
	mint(ll _v) { v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD; }
	friend bool operator==(const mint& a, const mint& b) {
		return a.v == b.v; }
	friend bool operator!=(const mint& a, const mint& b) {
		return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) {
		return a.v < b.v; }
	friend void re(mint& a) { ll x; re(x); a = mint(x); }
	friend string ts(mint a) { return ts(a.v); }

	mint& operator+=(const mint& m) {
		if ((v += m.v) >= MOD) v -= MOD;
		return *this; }
	mint& operator-=(const mint& m) {
		if ((v -= m.v) < 0) v += MOD;
		return *this; }
	mint& operator*=(const mint& m) {
		v = (ll)v*m.v%MOD; return *this; }
	mint& operator/=(const mint& m) { return (*this) *= inv(m); }
	friend mint pow(mint a, ll p) {
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans; }
	friend mint inv(const mint& a) { assert(a.v != 0);
		return pow(a,MOD-2); }

	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};

typedef mint<MOD,5> mi; // 5 is primitive root for both common mods
typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;

vector<vmi> scmb; // small combinations
void genComb(int SZ) {
	scmb.assign(SZ,vmi(SZ)); scmb[0][0] = 1;
	FOR(i,1,SZ) F0R(j,i+1)
		scmb[i][j] = scmb[i-1][j]+(j?scmb[i-1][j-1]:0);
}
ll comb(int a, int b) {
	if (a < b || b < 0) return 0;
	return (ll)fac[a]*ifac[b]%MOD*ifac[a-b]%MOD;
}
*//*
vi invs, fac, ifac;
void genFac(int SZ) { // pre-compute factorial mod inverses
	invs.resize(SZ), fac.resize(SZ), ifac.resize(SZ);
	invs[1] = fac[0] = ifac[0] = 1;
	FOR(i,2,SZ) invs[i] = MOD-(ll)MOD/i*invs[MOD%i]%MOD;
	FOR(i,1,SZ) {
		fac[i] = (ll)fac[i-1]*i%MOD;
		ifac[i] = (ll)ifac[i-1]*invs[i]%MOD;
	}
}
*/

ll gcd(ll a,ll b) {  return b?gcd(b,a%b):a;}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

void IOS(int n=10, string s=""){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.precision(n); cerr.precision(n); cerr << fixed; cout << fixed;
  if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

const int mxN = 2e5;

void solve(){
	ll n,d=1e9,d1=0,s=0; string ans; re(n); vl a(n),pa(n+1),c; re(a); F0R(i,n) pa[a[i]]=i;
	FOR(i,1,n+1){
		c.pb(pa[i]); chmin(d,pa[i]); chmax(d1,pa[i]);
		s+=pa[i];
		double h1= (d1-d+1),h=h1/2,e=h*(d+d1);
		//sort(all(c)); vi d(sz(c)); iota(all(d),c[0]);
		if((int)e==s) ans+='1';
		else ans+='0';
	}
	ps(ans);
}
int main(){
	IOS();
	int t=1; re(t);
	F0R(i,t){
		//pr("Case #",i+1,": ");
		solve();
	}
#ifdef __APPLE__
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<double,double>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTUU tcT, class ...U
#define tcTU tcT, class U
#define tcTU3 tcTU, class C
#define tcTU4 tcTU3, class D

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using mpq = priority_queue<T, vector<T>, greater<T>>;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

tcT> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key */

#define ut uint64_t
struct fhash {
    static ut s(ut x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
	}
    size_t operator()(ut x) const {
        static const ut r = chrono::steady_clock::now().time_since_epoch().count();
        return s(x+r);
	}
};
#define z(n) static_cast<decay<decltype(n)>::type>(n);
#define cbit(n, b) (((n)>>(b))&1)
#define sbit(n, b) ((n)|(z(1)<<(b)))
#define rbit(n, b) ((n)&~(z(1)<<(b)))
#define fbit(n, b) ((n)^(z(1)<<(b)))

#define ts to_string
#define fe first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(v) ((int)(v).size())
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

tcTU> T fstTrue(T lo, T hi, U f) {
	while (lo < hi) {
		T mid = (lo+hi)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	while (lo < hi) {
		T mid = (lo+hi+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}

const int di[4]={-1, 0, 1, 0}, dj[4]={0, 1, 0, -1};
const int di8[8]={-1, -1, 0, 1, 1, 1, 0, -1}, dj8[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int MOD = 1e9+7; //const int MOD =998244353;
const ld PI = acos((ld)-1);

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll randint(ll a, ll b) { return uniform_int_distribution<ll>(a, b)(rng);}

bool pow2(int i){ return i&&(i&-i)==i;}
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

tcT> bool chmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
tcT> bool chmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

tcT> void remDup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)),end(v)); }

// TO_STRING
tcTU3> string ts(tuple<T,U,C> p);
tcTU4> string ts(tuple<T,U,C,D> p);
string ts(char c) { return string(1,c); }
string ts(bool b) {
    #ifdef __APPLE__
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
tcT> string ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
string ts(vb v) {
	string res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string ts(bitset<SZ> b) {
	string res = ""; F0R(i,sz(b)) res += char('0'+b[i]);
	return res; }
tcTU> string ts(pair<T,U> p);
tcT> string ts(T v) { // containers with begin(), end()
	#ifdef __APPLE__
		bool fst = 1; string res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; string res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;
	#endif
}
tcTU> string ts(pair<T,U> p) {
	#ifdef __APPLE__
		return "("+ts(p.fe)+", "+ts(p.se)+")";
	#else
		return ts(p.fe)+" "+ts(p.se);
	#endif
}
tcTU3> string ts(tuple<T,U,C> p) {
	#ifdef __APPLE__
	    return "("+ts(get<0>(p))+","+ts(get<1>(p))+","+ts(get<2>(p))+")";
	#else
	    return ts(get<0>(p))+" "+ts(get<1>(p))+" "+ts(get<2>(p));
	#endif
}
tcTU4> string ts(tuple<T,U,C,D> p) {
	#ifdef __APPLE__
	    return "("+ts(get<0>(p))+","+ts(get<1>(p))+","+ts(get<2>(p))+","+ts(get<3>(p))+")";
	#else
	    return ts(get<0>(p))+" "+ts(get<1>(p))+" "+ts(get<2>(p))+" "+ts(get<3>(p));
	#endif
}
//INPUT  void re(string& d){getline(cin,d) ;getline(cin,d); }

tcTU3> void re(tuple<T,U,C>& p);
tcTU4> void re(tuple<T,U,C,D>& p);
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);

tcT, size_t SZ> void re(AR<T,SZ>& a);
tcT> void re(T& x) { cin >> x; }
void re(double& d) { string t; re(t); d = stod(t); }
void re(ld& d) { string t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }
tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(array<T,SZ>& x) { trav(a,x) re(a); }
tcTU3> void re(tuple<T,U,C>& p){re(get<0>(p),get<1>(p),get<2>(p));}
tcTU4> void re(tuple<T,U,C,D>& p){re(get<0>(p),get<1>(p),get<2>(p),get<3>(p));}
// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef __APPLE__ // chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

/*
template<int MOD, int RT> struct mint {
	static const int mod = MOD;
	static constexpr mint rt() { return RT; } // primitive root for FFT
	int v; explicit operator int() const { return v; } // explicit -> don't silently convert to int
	mint() { v = 0; }
	mint(ll _v) { v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD; }
	friend bool operator==(const mint& a, const mint& b) {
		return a.v == b.v; }
	friend bool operator!=(const mint& a, const mint& b) {
		return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) {
		return a.v < b.v; }
	friend void re(mint& a) { ll x; re(x); a = mint(x); }
	friend string ts(mint a) { return ts(a.v); }

	mint& operator+=(const mint& m) {
		if ((v += m.v) >= MOD) v -= MOD;
		return *this; }
	mint& operator-=(const mint& m) {
		if ((v -= m.v) < 0) v += MOD;
		return *this; }
	mint& operator*=(const mint& m) {
		v = (ll)v*m.v%MOD; return *this; }
	mint& operator/=(const mint& m) { return (*this) *= inv(m); }
	friend mint pow(mint a, ll p) {
		mint ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans; }
	friend mint inv(const mint& a) { assert(a.v != 0);
		return pow(a,MOD-2); }

	mint operator-() const { return mint(-v); }
	mint& operator++() { return *this += 1; }
	mint& operator--() { return *this -= 1; }
	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
};

typedef mint<MOD,5> mi; // 5 is primitive root for both common mods
typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;

vector<vmi> scmb; // small combinations
void genComb(int SZ) {
	scmb.assign(SZ,vmi(SZ)); scmb[0][0] = 1;
	FOR(i,1,SZ) F0R(j,i+1)
		scmb[i][j] = scmb[i-1][j]+(j?scmb[i-1][j-1]:0);
}
ll comb(int a, int b) {
	if (a < b || b < 0) return 0;
	return (ll)fac[a]*ifac[b]%MOD*ifac[a-b]%MOD;
}
*//*
vi invs, fac, ifac;
void genFac(int SZ) { // pre-compute factorial mod inverses
	invs.resize(SZ), fac.resize(SZ), ifac.resize(SZ);
	invs[1] = fac[0] = ifac[0] = 1;
	FOR(i,2,SZ) invs[i] = MOD-(ll)MOD/i*invs[MOD%i]%MOD;
	FOR(i,1,SZ) {
		fac[i] = (ll)fac[i-1]*i%MOD;
		ifac[i] = (ll)ifac[i-1]*invs[i]%MOD;
	}
}
*/

ll gcd(ll a,ll b) {  return b?gcd(b,a%b):a;}
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

void IOS(int n=10, string s=""){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.precision(n); cerr.precision(n); cerr << fixed; cout << fixed;
  if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

const int mxN = 2e5;

void solve(){
	ll n,d=1e9,d1=0,s=0; string ans; re(n); vl a(n),pa(n+1),c; re(a); F0R(i,n) pa[a[i]]=i;
	FOR(i,1,n+1){
		c.pb(pa[i]); chmin(d,pa[i]); chmax(d1,pa[i]);
		s+=pa[i];
		ld h1= (d1-d+1),h=h1/2,e=h*(d+d1);
		//sort(all(c)); vi d(sz(c)); iota(all(d),c[0]);
		if((int)e==s) ans+='1';
		else ans+='0';
	}
	ps(ans);
}
int main(){
	IOS();
	int t=1; re(t);
	F0R(i,t){
		//pr("Case #",i+1,": ");
		solve();
	}
#ifdef __APPLE__
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}