using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using static Codeforces.IO;
using static System.Linq.Enumerable;

namespace Codeforces
{
    static class IO
    {
        static StringBuilder builder = new StringBuilder();
        static Dummy dummy = new Dummy();
        class Dummy
        {
            ~Dummy()
            {
                Console.Write(builder);
            }
        }
        public static void Write(object obj)
        {
            builder.Append(obj);
        }
        public static void WriteLine(object obj)
        {
            builder.AppendLine(obj.ToString());
        }
        public static void Write(params object[] objs)
        {
            if (objs.Length != 0)
            {
                Write(objs[0]);
                for (var i = 1; i < objs.Length; ++i)
                {
                    Write(" ");
                    Write(objs[i]);
                }
            }
        }
        public static void WriteLine(params object[] objs)
        {
            Write(objs);
            WriteLine();
        }

        public static void WriteLine()
        {
            builder.AppendLine();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }
        public static T ReadLine<T>(Func<string, T> parser)
        {
            return parser(ReadLine());
        }
        public static T[] ReadArray<T>(Func<string, T> parser)
        {
            return ReadLine().Split(' ').Select(parser).ToArray();
        }
        public static (T, T) ReadTuple2<T>(Func<string, T> parser)
        {
            var ar = ReadArray(parser);
            return (ar[0], ar[1]);
        }
        public static (T, T, T) ReadTuple3<T>(Func<string, T> parser)
        {
            var ar = ReadArray(parser);
            return (ar[0], ar[1], ar[2]);
        }
    }

    static class Program
    {
        static void Main(string[] args)
        {
            var Q = ReadLine(int.Parse);
            foreach(var _ in Range(0, Q))
            {
                var N = ReadLine(int.Parse);
                var ar = ReadArray(int.Parse);
                var place = new int[N];
                foreach(var i in Range(0, N))
                {
                    --ar[i];
                    place[ar[i]] = i;
                }
                var lhs = N;
                var rhs = -1;
                foreach(var i in Range(0, N))
                {
                    lhs = Math.Min(lhs, place[i]);
                    rhs = Math.Max(rhs, place[i]);
                    Write((rhs - lhs == i) ? 1 : 0);
                }
                WriteLine();
            }
        }
    }
}


using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;
using System.Numerics;

static class Solution
{
    static long modPow(long v, long p, long mod)
    {
        if (p == 0)
            return 1;
        if (p == 1)
            return v;

        long add = 1;
        while (p > 1)
        {
            if (p % 2 == 1)
            {
                add *= v;
                add %= mod;
            }
            v = (v * v) % mod;
            p = p / 2;
        }
        return (v * add) % mod;
    }

    public static List<T> GetOrAddNew<K, T>(this Dictionary<K, List<T>> dic, K key)
    {
        if (dic == null) throw new ArgumentNullException();

        return (dic[key] = dic.ContainsKey(key) ? dic[key] : new List<T>());
    }

    public static V GetValueOrDefault<K, V>(this Dictionary<K, V> dic, K key)
    {
        if (dic == null) throw new ArgumentNullException();
        if (dic.ContainsKey(key))
            return dic[key];
        return default(V);

    }

    public static void AddOrSet<K>(this Dictionary<K, long> dic, K key, long add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;
    }

    public static void AddOrSet<K>(this Dictionary<K, int> dic, K key, int add)
    {
        if (dic == null) throw new ArgumentNullException();

        dic[key] = dic.GetValueOrDefault(key) + add;
    }

    static long readLong()
    {
        return long.Parse(Console.ReadLine().Trim());
    }

    static int readInt()
    {
        return int.Parse(Console.ReadLine().Trim());
    }

    static long[] readLongs()
    {
        return Array.ConvertAll(Console.ReadLine().Trim().Split(), long.Parse);
    }

    static int[] readInts(int add = 0)
    {
        return Array.ConvertAll(Console.ReadLine().Trim().Split(), el => int.Parse(el) + add);
    }

    static string[] readStrings()
    {
        return Console.ReadLine().Trim().Split();
    }

    static string readString()
    {
        return Console.ReadLine().Trim();
    }

    public static int readInt(this StreamReader str)
    {
        if (str == null) throw new ArgumentNullException();
        return int.Parse(str.ReadLine().Trim());
    }

    public static int[] readInts(this StreamReader str)
    {
        if (str == null) throw new ArgumentNullException();
        return Array.ConvertAll(str.ReadLine().Trim().Split(), int.Parse);
    }

    static StringBuilder WriteArray(StringBuilder sb, IEnumerable lst, string delimeter)
    {
        if (lst == null)
            throw new ArgumentNullException(nameof(lst));
        if (sb == null)
            throw new ArgumentNullException(nameof(sb));

        foreach (var el in lst)
        {
            sb.Append(el);
            if (delimeter != null)
                sb.Append(delimeter);
        }
        return sb;
    }

    static StringBuilder WriteObject(StringBuilder sb, object obj, string delimeter)
    {
        if (obj == null)
            throw new ArgumentNullException(nameof(obj));
        if (sb == null)
            throw new ArgumentNullException(nameof(sb));

        sb.Append(obj);
        if (delimeter != null)
            sb.Append(delimeter);
        return sb;
    }

    static void Write2DimArr<T>(this T[,] arr, string delimeter = " ", string delimeter2 = "\n")
    {
        if (arr == null)
            throw new ArgumentNullException(nameof(arr));

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            for (int j = 0; j < arr.GetLength(1); j++)
            {
                WriteObject(sb, arr[i, j], delimeter);
            }
            sb.Append(delimeter2);
        }
        Console.Write(sb.ToString());
    }

    static void Write(this object obj, string delimeter = " ")
    {
        if (obj == null)
            throw new ArgumentNullException(nameof(obj));

        var enm = obj as IEnumerable;
        StringBuilder sb = new StringBuilder();
        if (enm != null)
            WriteArray(sb, enm, delimeter);
        else
        {
            WriteObject(sb, obj, delimeter);
        }
        Console.Write(sb.ToString());
    }
    static void WriteLine(this object obj, string delimeter = " ")
    {
        obj.Write(delimeter);
        Console.WriteLine();
    }
    static void WriteS(params object[] obj)
    {
        obj.Write(" ");
    }
    static void WriteLineS(params object[] obj)
    {
        obj.WriteLine(" ");
    }

    static List<Tuple<int, int>> readEdges(int n)
    {
        List<Tuple<int, int>> res = new List<Tuple<int, int>>(n);
        for (int i = 0; i < n; i++)
        {
            var arr = readInts();
            res.Add(Tuple.Create(arr[0], arr[1]));
        }
        return res;
    }

    static Dictionary<int, List<Tuple<int, int>>> readWDicEdges(int n)
    {
        Dictionary<int, List<Tuple<int, int>>> dic =
            new Dictionary<int, List<Tuple<int, int>>>(n);
        for (int i = 0; i < n - 1; i++)
        {
            var arr = readInts();
            var tpl = Tuple.Create(arr[0], arr[1], arr[2]);
            dic[tpl.Item1] = dic.ContainsKey(tpl.Item1) ? dic[tpl.Item1] : new List<Tuple<int, int>>();
            dic[tpl.Item2] = dic.ContainsKey(tpl.Item2) ? dic[tpl.Item2] : new List<Tuple<int, int>>();

            dic[tpl.Item1].Add(Tuple.Create(tpl.Item2, tpl.Item3));
            dic[tpl.Item2].Add(Tuple.Create(tpl.Item1, tpl.Item3));

        }
        return dic;
    }

    static List<Tuple<int, int>> readWEdges(int n)
    {
        List<Tuple<int, int>> res = new List<Tuple<int, int>>(n);
        for (int i = 0; i < n; i++)
        {
            var arr = readInts();
            res.Add(Tuple.Create(arr[0], arr[1]));
        }
        return res;
    }
    static List<int>[] graphArr(int n)
    {
        return Enumerable.Range(0, n).Select(el => new List<int>()).ToArray();
    }

    static Dictionary<int, List<int>> readDicEdges(int n)
    {
        Dictionary<int, List<int>> dic =
            new Dictionary<int, List<int>>(n);

        for (int i = 0; i < n - 1; i++)
        {
            var arr = readInts();
            var tpl = Tuple.Create(arr[0], arr[1]);
            dic[tpl.Item1] = dic.ContainsKey(tpl.Item1) ? dic[tpl.Item1] : new List<int>();
            dic[tpl.Item2] = dic.ContainsKey(tpl.Item2) ? dic[tpl.Item2] : new List<int>();

            dic[tpl.Item1].Add(tpl.Item2);
            dic[tpl.Item2].Add(tpl.Item1);
        }
        return dic;
    }

    private static int LessOrEqual(List<int> arr, int val)
    {
        if (arr.Count == 0)
        {
            return -1;
        }
        int l = -1;
        int r = arr.Count;
        while (r - l > 1)
        {
            var cur = (l + r) / 2;
            if (arr[cur] <= val)
            {
                l = cur;
            }
            else
            {
                r = cur;
            }
        }

        return l;
    }

    private static int GetLength(int v)
    {
        if (v == 0)
            return 0;
        var ret = 0;
        while (v > 0)
        {
            ret++;
            v = v >> 1;
        }
        return ret;
    }

    private static void Main(string[] args)
    {
        int t = readInt();
        for (int k = 0; k < t; k++)
        {
            var n = readInt();
            int[] arr = readInts();
            Dictionary<int, int> dic = new Dictionary<int, int>(arr.Length);
            for (int i = 0; i < arr.Length; i++)
            {
                var el = arr[i];
                dic[el] = i;
            }
            bool[] res = new bool[arr.Length];
            res[0] = true;
            res[res.Length - 1] = true;

            int min = dic[1];
            int max = dic[1];
            for (int i = 2; i < arr.Length; i++){
                var  inx = dic[i];
                if (inx < min )
                    min = inx;
                else if(inx > max)
                    max = inx;

                if (max - min + 1 == i)
                    res[i-1] = true;
                else
                    res[i-1] = false;
            }

            res.Select(el=>el?'1':'0').WriteLine("");
        }
    }
}


/*

 */
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;

public class Solver
{
    public void Solve()
    {
        int tests = ReadInt();
        for (int test = 0; test < tests; test++)
        {
            int n = ReadInt();
            int[] a = ReadIntArray();
            int[] ainx = new int[n];
            for (int i = 0; i < n; i++)
                ainx[a[i]-1] = i;

            int max = ainx[0];
            int min = ainx[0];
            bool[] ans = new bool[n];
            ans[0] = true;
            for (int pi = 2; pi <= n; pi++)
            {
                max = Math.Max(max, ainx[pi-1]);
                min = Math.Min(min, ainx[pi-1]);
                ans[pi-1] = (max - min + 1) == pi;
            }
            Write(string.Concat(ans.Select(e => e ? '1' : '0')));
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        Debug.Listeners.Clear();
        Debug.Listeners.Add(new ConsoleTraceListener());
        Trace.Listeners.Clear();
        Trace.Listeners.Add(new ConsoleTraceListener());

        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        new Solver().Solve();
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


#[allow(unused_imports)]
//use proconio::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn solve(){
    let n:usize = read();
    let a:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut p:Vec<usize> = vec![0;n];
    for i in 0..n {
        p[a[i] - 1] = i;
    }
    let mut l = n;
    let mut r:usize = 0;
    let mut ans:Vec<char> = vec![' ';n];
    for i in 0..n {
        l = min(l,p[i]);
        r = max(r,p[i]);
        if(r - l == i){ans[i] = '1';}
        else {ans[i] = '0';}
    }
    for i in 0..n{
        if i < n - 1 {
            print!("{}", ans[i]);
        }
            else
            {println!("{}",ans[i]);
        }
    }
}
fn main() {
    let n:i64 = read();
    for i in 0..n {
        solve();
    }
}


#[allow(unused_imports)]
use proconio::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn solve(){
    let n:usize = read();
    let a:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut p:Vec<usize> = vec![0;n];
    for i in 0..n {
        p[a[i] - 1] = i;
    }
    let mut l = n;
    let mut r:usize = 0;
    let mut ans:Vec<char> = vec![' ';n];
    for i in 0..n {
        l = min(l,p[i]);
        r = max(r,p[i]);
        if(r - l == i){ans[i] = '1';}
        else {ans[i] = '0';}
    }
    for i in 0..n{
        if i < n - 1 {
            print!("{}", ans[i]);
        }
            else
            {println!("{}",ans[i]);
        }
    }
}
fn main() {
    let n:i64 = read();
    for i in 0..n {
        solve();
    }
}


#[allow(unused_imports)]
use proconio::*;
use std::cmp::*;
fn solve(){
    input!{
    n:usize,
    a:[usize;n]
    }
    let mut p:Vec<usize> = vec![0;n];
    for i in 0..n {
        p[a[i] - 1] = i;
    }
    let mut l = n;
    let mut r:usize = 0;
    let mut ans:Vec<char> = vec![' ';n];
    for i in 0..n {
        l = min(l,p[i]);
        r = max(r,p[i]);
        if(r - l == i){ans[i] = '1';}
        else {ans[i] = '0';}
    }
    for i in 0..n{
        if i < n - 1 {
            print!("{}", ans[i]);
        }
            else
            {println!("{}",ans[i]);
        }
    }
}
fn main() {
    input!{
    n:i64,
    }
    for i in 0..n {
        solve();
    }
}


#[allow(unused_imports)]
use std::cmp::{min,max};
use std::io::{ stdin};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main(){
    let mut scan = Scanner::default();
    //let out = &mut BufWriter::new(stdout());

    let t = scan.next::<usize>();
    for _x in 0..t{
        let n = scan.next::<usize>();
        let a: Vec<usize> = (0..n).map(|_| scan.next()).collect();
        println!("{}", solve(&a))
    }
}

fn solve(p: &[usize]) -> String{
    let mut res = "1".to_string();
    if p.len() == 1 {
        return res;
    }
    let mut idx = vec![0; p.len() + 1];
    for i in 1..=p.len() {
        idx[p[i - 1]] = i;
    }
    let mut left = idx[1];
    let mut right = idx[1];
    for m in 2..p.len() {
                if left > idx[m] {
            left = idx[m];
        }
        if right < idx[m] {
            right = idx[m];
        }
        if right - left == m - 1 {
            res.push_str("1")
        } else {
            res.push_str("0")
        }
    }
    res.push_str("1");
    return res;
}


#![allow(unused_imports)]

use core::borrow::Borrow;
use std::cell::RefCell;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::io::{self, Write};
use std::mem::swap;
use std::ops::Deref;
use std::rc::Rc;
use std::str;

struct Scanner<R> {
  reader: R,
  buf_str: Vec<u8>,
  buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> Scanner<R> {
  fn new(reader: R) -> Self {
    Self { reader, buf_str: Vec::new(), buf_iter: "".split_ascii_whitespace() }
  }
  fn token<T: str::FromStr>(&mut self) -> T {
    loop {
      if let Some(token) = self.buf_iter.next() {
        return token.parse().ok().expect("Failed parse");
      }
      self.buf_str.clear();
      self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
      self.buf_iter = unsafe {
        let slice = str::from_utf8_unchecked(&self.buf_str);
        std::mem::transmute(slice.split_ascii_whitespace())
      }
    }
  }
}

fn main() {
  let (stdin, stdout) = (io::stdin(), io::stdout());
  let mut scan = Scanner::new(stdin.lock());
  let mut out = io::BufWriter::new(stdout.lock());

  let n = scan.token::<i32>();
  for case in 0..n {
    let mut len = scan.token::<i32>();
    let mut input = (0..len).map(|x| scan.token()).collect::<Vec<i32>>();
    let lookup = input.iter().enumerate().map(|(idx, val)| (*val as i32, idx as i32) ).collect::<HashMap<i32, i32>>();
    let mut ans = vec![0; len as usize];
    let mut l = *lookup.get(&1).unwrap();
    let mut r = *lookup.get(&1).unwrap();
    ans[0] = 1;
    for i in 2..ans.len()+1 {
      let p = i as i32;
      let p_index = *lookup.get(&p).unwrap();
      if p_index < l { l = p_index; } else if p_index > r { r = p_index };
      let len = (r-l)+1;
      if p == len { ans[(p-1) as usize] = 1; }
     // println!( "p:{}, l:{} r:{}", p, l, r);
    }
    let ans_str = ans.iter().map(|x| x.to_string()).collect::<String>();
    writeln!(out, "{}", ans_str);
  }
  out.flush();
}


#[allow(unused_imports)]
use std::collections::*;
use std::io::prelude::*;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut entries = buf.split_whitespace();
    let q: usize = entries.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let n: usize = entries.next().unwrap().parse().unwrap();
        let mut p: Vec<usize> = Vec::with_capacity(n);
        for _ in 0..n {
            let p_i: usize = entries.next().unwrap().parse().unwrap();
            p.push(p_i);
        }
        println!("{}", solve(&p))
    }
}

fn solve(p: &[usize]) -> String {
    let mut res = "1".to_string();
    if p.len() == 1 {
        return res;
    }
    let mut idx = vec![0; p.len() + 1];
    for i in 1..=p.len() {
        idx[p[i - 1]] = i;
    }
    let mut left = idx[1];
    let mut right = idx[1];
    for m in 2..p.len() {
        if left > idx[m] {
            left = idx[m];
        }
        if right < idx[m] {
            right = idx[m];
        }
        if right - left == m - 1 {
            res.push_str("1")
        } else {
            res.push_str("0")
        }
    }
    res.push_str("1");
    res
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test1() {}
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var m, index int
		fmt.Scan(&m)
		a := make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&a[j])
			if a[j] == 1 {
				index = j
			}
		}
		cnt := 1
		sum := a[index]
		l := index - 1
		r := index + 1
		if cnt == sum {
			fmt.Print(1)
		} else {
			fmt.Print(0)
		}
		for j := 0; j < m-1; j++ {

			if l < 0 || (r < m && a[l] > a[r]) {
				sum += a[r]
				r++
			} else {
				sum += a[l]
				l--
			}
			cnt += j + 2
			if sum == cnt {
				fmt.Print(1)
			} else {
				fmt.Print(0)
			}

		}
		fmt.Print("\n")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(a ...interface{})            { fmt.Fscan(reader, a...) }
func main() {
	var n int
	scanf(&n)
	for i := 0; i < n; i++ {
		var m, index int
		scanf(&m)
		a := make([]int, m)
		for j := 0; j < m; j++ {
			scanf(&a[j])
			if a[j] == 1 {
				index = j
			}
		}
		cnt := 1
		sum := a[index]
		l := index - 1
		r := index + 1
		if cnt == sum {
			printf("1")
		} else {
			printf("0")
		}
		for j := 0; j < m-1; j++ {
			if l < 0 || (r < m && a[l] > a[r]) {
				sum += a[r]
				r++
			} else {
				sum += a[l]
				l--
			}
			cnt += j + 2
			if sum == cnt {
				printf("1")
			} else {
				printf("0")
			}
		}
		printf("\n")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var m, index int
		scanf("%d\n", &m)
		a := make([]int, m)
		for j := 0; j < m; j++ {
			if j<m-1 {
				scanf("%d", &a[j])
			}else{
				scanf("%d\n", &a[j])
			}
			if a[j] == 1 {
				index = j
			}
		}
		cnt := 1
		sum := a[index]
		l := index - 1
		r := index + 1
		if cnt == sum {
			printf("1")
		} else {
			printf("0")
		}
		for j := 0; j < m-1; j++ {
			if l < 0 || (r < m && a[l] > a[r]) {
				sum += a[r]
				r++
			} else {
				sum += a[l]
				l--
			}
			cnt += j + 2
			if sum == cnt {
				printf("1")
			} else {
				printf("0")
			}
		}
		printf("\n")
	}
}


package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func max(a,b int) int {
	if a>b {
		return a
	} else {
		return b
	}
}
func min(a,b int) int {
	if a>b {
		return b
	} else {
		return a
	}
}

type vector_i []int
func (v *vector_i) pb(x int) {
	*v=append(*v,x)
}
func (v *vector_i) size() int {
	return len(*v)
}
func (v *vector_i) pop() {
	if !(*v).empty() {
		*v=(*v)[:len(*v)-1]
	}
}
func (v *vector_i) reverse() {
	n:=(*v).size()
	for i:=0;i*2<n;i++ {
		(*v)[i],(*v)[n-i-1]=(*v)[n-i-1],(*v)[i]
	}
}
func (v *vector_i) clear() {
	*v=(*v)[:0]
}
func (v *vector_i) empty() bool {
	return (*v).size()==0
}
func (v *vector_i) sort() {
	sort.Slice(*v, func (i, j int) bool {
		return (*v)[i]<(*v)[j]
	})
}
type fun_ii_b func (i, j int) bool
func (v *vector_i) sort_fun(f fun_ii_b) {
	sort.Slice(*v,f)
}
func (v *vector_i) lb(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) ub(x int) int {
	var l,r int = 0,(*v).size()
	for l<r {
		mid:=(l+r)/2
		if (*v)[mid]<=x {
			l=mid+1
		} else {
			r=mid
		}
	}
	return l
}
func (v *vector_i) del(pos int) {
	if pos>=0 && pos<len(*v) {
		for i:=pos;i<len(*v)-1;i++ {
			(*v)[i]=(*v)[i+1]
		}
		(*v).pop()
	}
}
func (v *vector_i) ins(pos, val int) {
	(*v).pb(0)
	for i:=len(*v)-1;i>pos;i-- {
		(*v)[i]=(*v)[i-1]
	}
	(*v)[pos]=val
}
func (v *vector_i) substr(l, r int) vector_i {
	var ans vector_i=make(vector_i,r-l+1)
	for i:=l;i<=r;i++ {
		ans.pb((*v)[i])
	}
	return ans
}
func (v *vector_i) resize(n int) {
	for len(*v)>n {
		(*v).pop()
	}
	for len(*v)<n {
		(*v).pb(0)
	}
}

func main() {

	defer writer.Flush()

	var t int
	scanf("%d\n",&t)
	for ;t>0;t-- {
		var p,id vector_i
		var n int
		scanf("%d\n",&n)
		for i:=1;i<=n;i++ {
			var x int
			scanf("%d ",&x)
			p.pb(x)
			id.pb(i)
		}
		scanf("\n")
		id.sort_fun(func(i,j int) bool {
			return p[id[i]-1]<p[id[j]-1]
		})
		var mn,mx int=1e9,-1e9
		for j,i:=range id {
			mn=min(mn,i)
			mx=max(mx,i)
			if mx-mn==j {
				printf("1")
			} else {
				printf("0")
			}
		}
		printf("\n")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"io"
	"strings"
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main(){
	defer writer.Flush()
	T := reader.NextInt64()
	for t:=int64(0);t<T;t++{
		n:=(reader.NextInt())
		arr:=make([]int,n)
		for i:= range arr {
			arr[i]=reader.NextInt()
		}
		solve(arr,n)
	}
}

func solve(arr []int, n int){
	hm:=make(map[int]int,n+1)
	for i,val:=range arr {
		hm[val-1]=i
	}
	l:=n
	r:=0
	var b strings.Builder;
	b.Grow(n+1)
	for i:=0;i<n;i++ {
		l=Mn(l,hm[i])
		r=Mx(r,hm[i])
		if r-l == i {
			b.WriteString("1")
			// ans+="1"
		}else{
			b.WriteString("0")
			// ans+="0"
		}
	}
	writer.Printf("%s \n", b.String())
	return
}

func Mn (a,b int)int {
	if a<b{
		return a
	}
	return b
}
func Mx (a,b int)int {
	if a<b{
		return b
	}
	return a
}
func abs(a int64)int64{
	if(a>=0){
		return a
	}
	return -a
}

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}


package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var n int
var P []int

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n = ReadInt()
		P = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	pos := make([]int, n+1)
	for i := 0; i < n; i++ {
		p := P[i]
		pos[p] = i
	}

	answers := make([]rune, n)

	l, r := pos[1], pos[1]
	answers[0] = '1'
	for i := 2; i <= n; i++ {
		ChMin(&l, pos[i])
		ChMax(&r, pos[i])

		dist := r - l + 1
		if dist == i {
			answers[i-1] = '1'
		} else {
			answers[i-1] = '0'
		}
	}

	fmt.Println(string(answers))
}

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		n, a := readInts(0)
		ans := solve(n, a)
		for _, v := range ans {
			printf("%d", v)
		}
		println()
	}

}

func solve(n int, a []int) []int {
	w := make([]int, n+1)
	var b [2][]int
	for i := 0; i < n && a[i] != 1; i++ {
		b[0] = append(b[0], a[i])
		w[a[i]] = 0
	}
	for i := n - 1; 0 <= i && a[i] != 1; i-- {
		b[1] = append(b[1], a[i])
		w[a[i]] = 1
	}
	reverse(b[0])
	reverse(b[1])

	res := make([]int, n+1)
	res[n] = 1
	res[1] = 1
	c := 1
	m := make(map[int]bool)
	for i := 2; i < n; i++ {
		d := w[i]
		if !m[i] {
			var j int
			for j = 0; j < len(b[d]); j++ {
				c++
				v := b[d][j]
				m[v] = true
				if v == i {
					j++
					break
				}
			}
			b[d] = b[d][j:]
		}
		if c == i {
			res[i] = 1
		}
	}
	return res[1:]
}

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

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

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

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		n, a := readInts(0)
		ans := solve(n, a)
		for _, v := range ans {
			printf("%d", v)
		}
		println()
	}

}

func solve(n int, a []int) []int {
	p := make([]int, n+1)
	for i, v := range a {
		p[v] = i
	}
	res := make([]int, n+1)
	l, r := n, -1
	for i := 1; i <= n; i++ {
		r = max(r, p[i])
		l = min(l, p[i])
		if r-l+1 == i {
			res[i] = 1
		}
	}
	return res[1:]
}

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

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

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

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

const MOD = 1000000000 + 7

var t int
var n int
var P []int

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		n = ReadInt()
		P = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	idx := make([]int, n+1)
	for i, ele := range P {
		idx[ele] = i
	}

	min, max := idx[1], idx[1]
	answers := make([]rune, n+1)

	for i := 1; i <= n; i++ {
		if idx[i] > max {
			max = idx[i]
		}
		if idx[i] < min {
			min = idx[i]
		}

		if max-min == i-1 {
			answers[i] = '1'
		} else {
			answers[i] = '0'

		}
	}
	fmt.Println(string(answers[1:]))
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		// input
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		arr := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}
		fmt.Fscanf(in, "\n")

		beautifulNumbers(arr)
	}
}

func beautifulNumbers(arr []int) {
	idx := make([]int, len(arr)+1)
	for i, ele := range arr {
		idx[ele] = i
	}

	min, max := idx[1], idx[1]
	answers := make([]rune, len(arr)+1)

	for i := 1; i <= len(arr); i++ {
		if idx[i] > max {
			max = idx[i]
		}
		if idx[i] < min {
			min = idx[i]
		}

		if max-min == i-1 {
			answers[i] = '1'
		} else {
			answers[i] = '0'

		}
	}
	fmt.Println(string(answers[1:]))
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		// input
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		arr := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}
		fmt.Fscanf(in, "\n")

		beautifulNumbers(arr)
	}
}

func beautifulNumbers(arr []int) {
	idx := make([]int, len(arr)+1)
	for i, ele := range arr {
		idx[ele] = i
	}
	//fmt.Println("[", idx, "]")

	min, max := idx[1], idx[1]
	for i := 1; i <= len(arr); i++ {
		if idx[i] > max {
			max = idx[i]
		}
		if idx[i] < min {
			min = idx[i]
		}

		if max-min == i-1 {
			fmt.Print(1)
		} else {
			fmt.Print(0)

		}
	}
	fmt.Print("\n")
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		// input
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		arr := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}
		fmt.Fscanf(in, "\n")

		beautifulNumbers(arr)

	}
}

func beautifulNumbers(arr []int) {
	idx := make([]int, 200001)
	for i, ele := range arr {
		idx[ele] = i
	}

	// debug
	//for i := 1; i <= len(arr); i++ {
	//	fmt.Print(idx[i])
	//}
	//fmt.Print("\n")

	min, max := idx[1], idx[1]
	for i := 1; i <= len(arr); i++ {
		if idx[i] > max {
			max = idx[i]
		}
		if idx[i] < min {
			min = idx[i]
		}

		if max-min == i-1 {
			//fmt.Println("[min, max, i", min, max, i, "]")
			fmt.Print(1)
		} else {
			fmt.Print(0)

		}
	}
	fmt.Print("\n")
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		// input
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		arr := make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscanf(in, "%d", &arr[j])
		}
		fmt.Fscanf(in, "\n")

		beautifulNumbers(arr)
	}
}

func beautifulNumbers(arr []int) {
	idx := make([]int, len(arr)+1)
	for i, ele := range arr {
		idx[ele] = i
	}
	//fmt.Println(idx[1:])

	min, max := len(arr)+1, -1
	for i := 1; i <= len(arr); i++ {
		ChMax(&max, idx[i])
		ChMin(&min, idx[i])

		if max-min+1 == i {
			fmt.Print(1)
		} else {
			fmt.Print(0)

		}
	}
	fmt.Print("\n")
}

func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
// then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader=bufio.NewReader(os.Stdin)
var writer *bufio.Writer=bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}){fmt.Fprintf(writer,f,a...)}
func scanf(f string,a...interface{}){fmt.Fscanf(reader,f,a...)}

var ind,a [200010]int

func main(){
	defer writer.Flush()
	var T int
	scanf("%d\n",&T)
	for cas:=1;cas<=T;cas++{
		var n int
		scanf("%d\n",&n)
		for i:=0;i<n;i++{
			if i<n-1{
				scanf("%d",&a[i])
				ind[a[i]]=i
			}else{
				scanf("%d\n",&a[i])
				ind[a[i]]=i
			}
		}
		l,r:=ind[1],ind[1]
		for i:=1;i<=n;i++{
			if ind[i]<l{
				l=ind[i]
			}
			if ind[i]>r{
				r=ind[i]
			}
			if r-l+1==i {
				printf("1")
			}else{
				printf("0")
			}
		}
		printf("\n")
	}
}


import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')

t = int(input())
for _ in range(t):
	n = int(input())
	arr = map(int,input().split(" "))
	dic = [0]*(n+1)
	for i,v in enumerate(arr):
		dic[v] = i
	ret = ["1"]
	low,high = dic[1],dic[1]
	for i in range(2,n+1):
		low = min(low,dic[i])
		high = max(high,dic[i])

		if high - low == i - 1:
			ret.append("1")
		else:
			ret.append("0")
	print "".join(ret)


#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = int(2e5) + 100

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr = [(arr[i], i+1) for i in range(n)]
	arr.sort()
	minInd, maxInd = inf, 0
	ans = []
	for ele in arr:
		minInd = min(minInd, ele[1])
		maxInd = max(maxInd, ele[1])
		if maxInd-minInd+1 == ele[0]:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))

def main():
	for _ in range(int(input())):
		solve()

BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)

	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()


for i in range(input()):
    n = input()
    a = map(int, raw_input().split())
    p = [0] * n
    for i in range(n):
        p[a[i] - 1] = i
    l = r = p[0]
    ret = '1'
    for i in range(1, n):
        pos = p[i]
        l = min(l, pos)
        r = max(r, pos)
        ret += '1' if r - l == i else '0'
    print ret


for i in range(input()):
    n = input()
    a = map(int, raw_input().split())
    p = [0] * n
    for i in range(n):
        p[a[i] - 1] = i
    l = r = p[0]
    ret = [0] * n
    ret[0] = 1
    for i in range(1, n):
        pos = p[i]
        l = min(l, pos)
        r = max(r, pos)
        if r - l == i:
            ret[i] = 1
    print ''.join(map(str, ret))


from collections import Counter
from sys import stdin
raw_input = stdin.readline
for t in range(input()):
    n=input()
    l=map(int,raw_input().split())
    pos=Counter()
    for i in range(n):
        pos[l[i]]=i
    mn,mx=pos[1],pos[1]
    ans=['0']*n
    ans[0]='1'
    for i in range(2,n+1):
        #print mn,mx,pos[i],i
        if pos[i]==mn-1 or pos[i]==mx+1:
            if mx-mn+1==i-1:
                ans[i-1]='1'
        elif pos[i]>mn and pos[i]<mx:
            #print 'True',mx-mn+1,i,
            if mx-mn+1==i:
                #print 'True',mx-mn+1,i,
                ans[i-1]='1'
            #print ans
        mn=min(mn,pos[i])
        mx=max(mx,pos[i])
    print ''.join(ans)


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

class RangeQuery:
    def __init__(self, data, func=min):
        self.func = func
        self._data = _data = [list(data)]
        i, n = 1, len(_data[0])
        while 2 * i <= n:
            prev = _data[-1]
            _data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
            i <<= 1

    def query(self, begin, end):
        depth = (end - begin).bit_length() - 1
        return self.func(self._data[depth][begin], self._data[depth][end - (1 << depth)])

def main():
    t = int(input())

    for _ in range(t):
        n = int(input())

        ind = [-1] * n
        for i, j in enumerate(map(int, input().split())):
            ind[j - 1] = i

        rmi = RangeQuery(ind)
        rma = RangeQuery(ind, max)

        s = [0] * n

        for m in range(n):
            mi = rmi.query(0, m + 1)
            ma = rma.query(0, m + 1)
            s[m] = int(abs(ma - mi) == m)

        print(*s, sep='')

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


# Author : raj1307 - Raj Singh
# Date   : 5.12.19

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    for _ in range(ii()):
        n=ii()
        a=li()

        l=a.index(1)

        r=l
        x=[1]
        m=2
        s=1

        if n==1:
            print(1)
            continue

        while True:

            p=1000000
            q=1000000

            if l-1>=0:
                p=a[l-1]

            if r+1<=n-1:
                q=a[r+1]

            if p<q:
                s+=p
                l-=1
            else:
                s+=q
                r+=1

            if (m*(m+1))//2==s:
                x.append(1)
            else:
                x.append(0)

            if l==0 and r==n-1:
                break

            m+=1

        for i in x:
            print(i,end='')

        print()

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()


# Author : raj1307 - Raj Singh
# Date   : 5.12.19

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def msi(): return map(str,input().strip().split(" "))
def li(): return list(mi())

def dmain():
    sys.setrecursionlimit(100000000)
    threading.stack_size(40960000)
    thread = threading.Thread(target=main)
    thread.start()

#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
#from math import ceil,floor,log,sqrt,factorial,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading
#from itertools import permutations

abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[0]
def sort2(l):return sorted(l, key=getKey)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]

def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def main():

    for _ in range(ii()):
        n=ii()
        a=li()

        l=a.index(1)
        r=l

        x=[1]

        m=2
        f=2

        p=0
        s=1
        while True:

            p=1000000
            q=1000000

            if l-1>=0:
                p=a[l-1]

            if r+1<=n-1:
                q=a[r+1]

            if p<q:
                s+=p
                l-=1
            else:
                s+=q
                r+=1

            if (m*(m+1))//2==s:
                x.append(1)
            else:
                x.append(0)

            if l==0 and r==n-1:
                break

            m+=1

        for i in x:
            print(i,end='')

        print()

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()


t = input()

def getResult(n, p):
    aux = {}

    for i in range(n):
        aux[p[i]] = i

    l = aux[1]
    r = aux[1]
    result = []

    for i in range(n):
        r = max(r, aux[i + 1])
        l = min(l, aux[i + 1])

        if ((r - l) == i):
            result.append('1')
        else:
            result.append('0')

    return result

for i in range(t):
    n = input()
    p = map(int, raw_input().split())
    print(''.join(getResult(n, p)))


import sys
input=sys.stdin.readline
for _ in range(int(input())):
    n=int(input())
    l=[int(i) for i in input().split()]
    ans=[0]*(n+1)
    ind={}
    for i in range(n):
        ind[l[i]]=i+1
    clr=[0]*(n+1)
    lo=0
    hi=0
    hi=lo=ind[1]
    for i in range(1,n+1):
        clr[ind[i]]=1
        lo=min(lo,ind[i])
        hi=max(hi,ind[i])
        if hi-lo+1==i:
            ans[i]=1
    print ''.join(str(ans[i]) for i in range(1,n+1))


'''input
3
6
4 5 1 3 2 6
5
5 3 1 2 4
4
1 4 3 2
'''

import sys
debug = 1
readln = sys.stdin.readline

def write(s):
    sys.stdout.write(s)

def writeln(s):
    sys.stdout.write(s)
    sys.stdout.write('\n')

def readint():
    return int(readln())

def readints():
    return map(int, readln().split())

def readstr():
    return readln()

def readstrs():
    return readln().split()

def dprint(*args):
    if debug: print(' '.join(map(str, args)))

def solve(ints):
    indices = {}
    n = len(ints)
    for i in xrange(n):
        indices[ints[i]] = i

    l = indices[1]
    r = indices[1]
    ret = ['1']

    for i in xrange(2, n+1):
        idx = indices[i]
        if idx < l: l = idx
        if idx > r: r = idx
        if (r - l + 1) == i:
            ret.append('1')
        else:
            ret.append('0')
    return ''.join(ret)

t = readint()
for _ in xrange(t):
    n = readint()
    ints = readints()
    print solve(ints)


for _ in range(int(input())):
    n=int(input())
    b=[0]*n
    st=set()
    a=[int(i) for i in input().split()]
    for i in range(len(a)):
        b[a[i]-1]=i
    mini,maxi=b[0],b[0]
    ans=[]
    for i in b:
        st.add(i)
        if i<mini: mini=i
        if i>maxi: maxi=i
        if len(st)==(maxi-mini)+1: ans.append(1)
        else: ans.append(0)
    for i in ans:
        print(i,end='')
    print()


from sys import stdin,stdout
for _ in range(int(stdin.readline())):
    n=int(stdin.readline())
    a=list(map(int,stdin.readline().split()))
    vi=[0]*(1+n);ans='1'
    for i in range(n):
        vi[a[i]]=i
    mn=mx=vi[1]
    stdout.write('1')
    for i in range(2,1+n):
        mn=min(mn,vi[i])
        mx=max(mx,vi[i])
        if mx - mn + 1 == i:stdout.write('1')
        else:stdout.write('0')
    print()


from sys import stdin,stdout
for _ in range(int(stdin.readline())):
    n=int(stdin.readline())
    a=list(map(int,stdin.readline().split()))
    vi=[0]*(1+n);ans='1'
    for i in range(n):
        vi[a[i]]=i
    mn=mx=vi[1]
    for i in range(2,1+n):
        mn=min(mn,vi[i])
        mx=max(mx,vi[i])
        if mx - mn + 1 == i:
            ans += '1'
        else:
            ans += '0'
    print(ans)


from sys import stdin,stdout
for _ in range(int(stdin.readline())):
    n=int(stdin.readline())
    a=list(map(int,stdin.readline().split()))
    vi=[0]*(1+n);ans=''
    for i in range(n):
        vi[a[i]]=i
    mn=[0]*(1+n)
    mx=[0]*(1+n)
    mn[1]=mx[1]=vi[1]
    for i in range(2,1+n):
        mn[i]=min(mn[i-1],vi[i])
        mx[i]=max(mx[i-1],vi[i])
    for i in range(1,n+1):
        if mx[i]-mn[i]+1==i:ans+='1'
        else:ans+='0'
    print(ans)


#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<queue>
#define ll long long
using namespace std;
int a,b,c,n,m,T,x[1000];
char A[1000],B[100010];
int main(){
	scanf("%d%d",&n,&m);getchar();
	for(int i=1;i<=n;i++)scanf("%c",&A[i]);
	int j=0;
	for(int i=2;i<=n;i++){
		while(j&&A[i]!=A[j+1])j=x[j];
		if(A[i]==A[j+1])j++;
		x[i]=j;
	}
	j=1;
//	for(int i=1;i<=n;i++)cout<<x[i];
	for(int i=1;i<=m;i++){
		for(j;j<=n;j++){
			cout<<A[j];
		}
		j=x[n];
		j++;
	}
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<set>
#include<queue>
#include<vector>
typedef long long ll;
using namespace std;
int n, k;
string s;
string nnew;
int main()
{
	cin >> n >> k;
	cin >> s;
	int length = s.length();
	int i;
	for (i = 1; i <length; i++)
	{
		int  k = i;
		for (int j = 0; j < length; j++)
		{
			if (k == length)
			{

				goto end;
			}
			if (s[k] == s[j])
			{
				k++;
			}
			else
			{
				break;
			}
		}
	}
end:
	//cout << i << endl;
	int kk=0;
	for (kk = 0; kk < i; kk++)
	{
		//cout << kk << endl;
		nnew += s[kk];
	}
	//cout << "***" << endl;
	//nnew[kk] = '\0';
	//cout << nnew << endl;
	string ans;
	for (int i = 1; i < k; i++)
	{
		ans += nnew;
	}
	ans += s;
	cout << ans;
	return 0;
}


#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int next[1000005];

//得到next数组的过程也是模式串自身匹配的过程
void GetNext(char *p)
{
    int plen=strlen(p);
    //特判一种情况，第一位就对不齐的情况
    next[0]=-1;
    //k为前缀，j为后缀
    int k=-1;
    int j=0;
    while(j<plen)
    {
        //特判一种情况，第一位就对不齐的情况
        if(k==-1||p[j]==p[k])
        {
            k++;
            j++;
            //这里是优化next数组
            //if(p[j]!=p[k])
            next[j]=k;
            //else next[j]=next[k];
        }
        else
        {
            k=next[k];
        }
    }
}

void kmp(char *s,char *p)
{
    int i=0;
    int j=0;
    int sLen = strlen(s);
    int pLen = strlen(p);
    while(i<sLen )
    {
        if(j == -1 || s[i] == p[j])
        {
            i++;
            j++;
        }
        else//若是字符不匹配
        {
            //这里相当于将j减去一个j-next[j]
            //联想一下那个匹配的图，主串不动，模式串变化，即为模式串相当于主串滑动
            //即相当于模式串向右滑动了j-next[j]位

            //若不匹配则直接将模式串向右移动j-next[j]位。
            j = next[j];
        }
        if(j==pLen)
        {
            printf("%d\n",i-j+1);
            j=next[j];
        }
    }

}
char a[1000005],b[1000005];
int n,num;
int main()
{
    cin>>n>>num;
    cin>>a;
    GetNext(a);

    int i=0;
    for(int j=0;i<num;)
    {
        if(a[j])
        printf("%c",a[j++]);
        else
        {
            j=next[j];
            i++;
        }
    }
    return 0;
}


#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define int unsigned long long
using namespace std;
inline int read()
{
	int x=0,f=1,ch=getchar();
	while(ch>'9' || ch<'0')
	{
		if(ch=='-')
		f=-1;
		ch=getchar();
	}
	while(ch<='9' && ch>='0')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int n,k;
char a[105];
int pre[105];
int prime=133331;
void Pre()
{
	int res=0;
	for(int i=1;i<=n;i++)
	{
		res=res*prime+(int)(a[i]-'a'+1);
		pre[i]=res;
	}
}
int flag=0;
int mul(int x,int y)
{
	int res=1;
	while(y)
	{
		if(y & 1)
		res=res*x;
		x=x*x;
		y>>=1;
	}
	return res;
}
int Get(int l,int r)
{
	return pre[r]-pre[l-1]*mul(prime,r-l+1);
}
signed main()
{
	n=read(),k=read();
	scanf("%s",a+1);
	Pre();
	int now,place;
	for(now=2;now<=n;now++)
	{
		int wns1=Get(1,n-now+1);
		int wns2=Get(now,n);
		if(wns1==wns2)
		{
			flag=1;
			place=n-now+2;
			break;
		}
	}
	if(flag==0)
	{
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=n;j++)
			cout<<a[j];
		}
		cout<<endl;
	}
	else
	{
		for(int i=1;i<=n;i++)
		cout<<a[i];
		for(int i=1;i<=k-1;i++)
		{
			for(int j=place;j<=n;j++)
			cout<<a[j];
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <unordered_map>
#include <cstring>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int n,k;
char s[55];

int Next[55];
void cal_next(char *s)
{
    Next[1] = 0;
    for(int i = 2,j = 0; i <= n; ++i){
        while(j > 0 && s[i] != s[j+1])
            j = Next[j];
        if(s[i] == s[j+1])
            ++j;
        Next[i] = j;
    }
}

int main()
{
    cin >> n >> k;
    cin >> (s+1);
    cout << (s+1);
    cal_next(s);
    for(int i = 1; i < k; ++i){
		for(int j = Next[n]; j < n; ++j)
            printf("%c",s[j+1]);
	}
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <string>
using namespace std;
int nnext[55];
char s1[50005],s2[55];
int cnt;
void KMP_next(int l2)
{
	nnext[1]=0;
	int i=0;
	for(int j=2; j<=l2; j++)
	{
		while(i&&s2[j]!=s2[i+1])
			i=nnext[i];
		if(s2[i+1]==s2[j]) i++;
		nnext[j]=i;
	}

}

int KMP(int l2)
{
	int j=1,i=0;
	KMP_next(l2);
	s1[i]=s2[j];
	while(cnt)
	{
		//printf("11\n");
		while(j<l2){
			s1[++i]=s2[++j];
			//printf("%c %d\n",s1[i],i);
		}
		if(j>=l2) cnt--;
		j=nnext[j];
	}
	return i;
}

int main()
{
	int l,k;
	scanf("%d %d",&l,&k);
	scanf("%s",s2+1);
	cnt=k;
	int ll=KMP(l);
	//KMP_next(l);
	//for(int i=1; i<=l; i++)
	//	printf("%d",next[i]);
	for(int i=0; i<=ll; i++)
	{
		printf("%c",s1[i]);
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000005];
int p[1000005],lens;
void pre()
{
	p[1]=0;
	int j=0;
	for(int i=1;i<lens;i++){
		while(j>0&&s[i+1]!=s[j+1]){
			j=p[j];
		}
		if(s[i+1]==s[j+1]){
			j++;
		}
		p[i+1]=j;
	}
}

int main()
{
	int m,i;
	scanf("%d%d\n",&lens,&m);
	scanf("%s",s+1);
	pre();
	for(i=1;i<=lens;i++){
		printf("%c",s[i]);
	}
	m--;
	while(m--){
		if(p[lens]==0){
			for(i=1;i<=lens;i++){
				printf("%c",s[i]);
			}
		}
		else{
			for(i=lens-p[lens];i<=lens;i++){
				printf("%c",s[i]);
			}
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string a;
int n,m;
int main(){
	cin>>n>>m;
	cin>>a;
	for(int i=1;i<=m;i++) cout<<a;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int n,k;
char s[100];
int nex[100];
void getnex()
{
	int j=0;
	for(int i=2;i<=n;++i)
	{
		j=nex[i-1];
		while(j&&s[j+1]!=s[i])j=nex[j];
		if(s[j+1]==s[i])nex[i]=j+1;
		else nex[i]=0;
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)cin>>s[i];
	getnex();
	int tot=0;
	int pos=1;
	while(tot<k)
	{
		for(int i=pos;i<=n;++i)
			cout<<s[i];
		pos=nex[n]+1;tot++;
	}
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
const int N=55;
char s[N],p[N];
int ne[N];
int main()
{
    int n,k;
    cin>>n>>k>>p+1;
    for(int i=2,j=0;i<=n;i++)
    {
        while(j && p[j+1]!=p[i])    j=ne[i];
        if(p[j+1]==p[i])     j++;
        ne[i]=j;
    }
    for(int i=1;i<=n;i++)  cout<<p[i];
    for(int i=1;i<k;i++)
        for(int j=ne[n]+1;j<=n;j++)
            cout<<p[j];
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e7+10;
int Next[maxn];
void getnext(string s)
{
	int len=s.size();
	Next[0]=-1;
	int k=-1,j=0;
	while(j<len)
	{
		if(k==-1||s[k]==s[j])
		{
			k++;
			j++;
//			if(s[j]!=s[k])
			Next[j]=k;
//			else Next[j]=Next[k];
		}
		else k=Next[k];
	}
}
void KMP(string s1,string s2)
{
	int l1=s1.size();
	int l2=s2.size();
	int i=0,j=0;
	while(i<l1&&j<l2)
	{
		if(j==-1||s1[i]==s2[j])
		{
			i++;
			j++;
		}
		else j=Next[j];
	}
	if(j==l2) cout<<i-j<<endl;
	else cout<<-1<<endl;
}
int main()
{
	int n,k;
	string t,s1,s2;
	cin>>n>>k;
	cin>>t;
//    cin>>s1>>s2;
	getnext(t);
//	KMP(s1,s2);
    int len=t.size();
    for(int i=1;i<=k;i++)
    {
    	for(int j=0;j<len-Next[len];j++)
    	{
    		cout<<t[j];
		}
	}
	for(int i=len-Next[len];i<len;i++) cout<<t[i];
	//cout<<Next[s2.size()]<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <functional>
#include <math.h>
#include <memory.h>
#include <map>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include<memory>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
int n,k;
string x;
cin>>n>>k>>x;k--;
map<string,bool> m;
for(int i=1;i<n;++i) m[x.substr(n-i,i)]=1;
int maxx=0;
while(maxx<n-1&&m[x.substr(0,maxx+1)])maxx++;
string add=x.substr(maxx);
cout<<x;
while(k--) cout<<add;
return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <string>
using namespace std;
int next[55];
char s1[55],s2[55];
int cnt;
void KMP_next(int l2)
{
	next[1]=0;
	int i=0;
	for(int j=2; j<=l2; j++)
	{
		while(i&&s2[j]!=s2[i+1])
			i=next[i];
		if(s2[i+1]==s2[j]) i++;
		next[j]=i;
	}

}

int KMP(int l2)
{
	int j=1,i=0;
	KMP_next(l2);
	s1[i]=s2[j];
	while(cnt)
	{
		//printf("11\n");
		while(j<l2){
			s1[++i]=s2[++j];
			//printf("%c %d\n",s1[i],i);
		}
		if(j>=l2) cnt--;
		j=next[j];
	}
	return i;
}

int main()
{
	int l,k;
	scanf("%d %d",&l,&k);
	scanf("%s",s2+1);
	cnt=k;
	int ll=KMP(l);
	//KMP_next(l);
	//for(int i=1; i<=l; i++)
	//	printf("%d",next[i]);
	for(int i=0; i<=ll; i++)
	{
		printf("%c",s1[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

int n,k;
string pat;
string ans="";

int nxt[55];

void getNext(int lengthP)
{
    int j=0,k=-1;
    nxt[0]=-1;
    while(j<lengthP)
    {
        if(k==-1||pat[j]==pat[k])j++,k++,nxt[j]=k;
        else k=nxt[k];
    }
}

int main()
{
    cin>>n>>k;
    cin>>pat;
    getNext(n);
    ans=pat;
    for(int i=2;i<=k;i++)ans+=pat.substr(nxt[n],n-nxt[n]);
    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int t;
int nex[10100];
char a[101001];
string ans;
int main(){
	cin>>n>>t;

	cin>>a+1;
	nex[1]=0;
	int k=0;
	for(int i=2;i<=n;i++){
		while(a[k+1]!=a[i]&&k!=0) k=nex[k];
		if(a[k+1]==a[i]) k++;
		nex[i]=k;
	}

	int z=n-nex[n];

	t--;
	for(int i=1;i<=n;i++){
		 cout<<a[i];
	}
	while(t--){
		for(int i=n-z+1;i<=n;i++){
			cout<<a[i];
		}
	}

}


#include<cstdio>
using namespace std;
const int N=100;
int n,k,next[N];
char s[N],ans[N*N];
bool b[N*N];
bool bbb(int i){
	int j=0;
	for(;ans[i+j];j++)
		if(ans[i+j]!=s[j])return 0;
	for(;j<n;j++)
		ans[i+j]=s[j];
}
int main(){
	scanf("%d%d%s",&n,&k,s);
	for(int i=0,cnt=1;cnt<=k;i++){
		if(!ans[i]){
			for(int j=0;j<n;j++)
				ans[j+i]=s[j];
			cnt++;
		}
		else if(bbb(i))cnt++;
	}
	printf("%s",ans);
	return 0;
}


//
//  main.cpp
//  Luogu
//
//  Created by gengyf on 2019/7/1.
//  Copyright © 2019 yifan Geng. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
string str;
int n,k;
int main(){
    cin>>n>>k;
    cin>>str;
    int len=str.length();
    for(int i=1;i<len;i++){
        bool flag=true;
        for(int j=0;j<len-i;j++){
            if(str[j]!=str[i+j]){
                flag=false;
                break;
            }
        }
        if(flag==true){
            cout<<str;
            for(int d=2;d<=k;d++)
                for(int s=len-i;s<len;s++){
                    cout<<str[s];
                }
            return 0;
        }
    }
    for(int i=1;i<=k;i++){
        cout<<str;
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int f[60],n,k;
char s[60];
void Cal_Next(){
    f[0]=f[1]=0;
    for(int i=1;i<n;i++){
        int j=f[i];
        while(j>0 && s[i]!=s[j])j=f[j];
        if(s[i]==s[j])f[i+1]=j+1;
        else f[i+1]=0;
    }
}
int main(){
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    Cal_Next();
    printf("%s",s);
    for(int i=1;i<k;i++){
        for(int j=f[n];j<n;j++)printf("%c",s[j]);
    }
}


#include<iostream>
using namespace std;

int main()
{
	char t[600];
	int n, k;
	cin >> n >> k;
	scanf("%s", t);
	int lt = strlen(t);
	int *pre = new int[lt];
	pre[0] = -1;
	for (int i = 1, k = -1; i < lt; i++)
	{
		while (k >= 0 && t[k + 1] != t[i])k = pre[k];
		if (t[k + 1] == t[i])k++;
		pre[i] = k;
	}

	cout << t;
	for (int i = 2; i <= k; i++)
	{
		printf("%s", t + pre[lt - 1] + 1);
	}

	system("pause");
	return 0;
}


#include<iostream>
using namespace std;
const int maxn=100010;
int n,k,nexts[maxn];
string s,t;
void setNext(){
	nexts[0]=-1;
	int i=0,j=-1;
	while(i<s.length()){
		if(j==-1||s[i]==s[j]){
			i++;
			j++;
			nexts[i]=j;
		}else{
			j=nexts[j];
		}
	}
}

int main(){
	cin>>n>>k>>s;
	setNext();
	for(int i=0;i<n-nexts[n];i++){
		t+=s[i];
	}
	for(int i=1;i<=k-1;i++){
		cout<<t;
	}
	cout<<s;
	return 0;
}


#include<iostream>
using namespace std;
const int maxn=100010;
int n,k,next[maxn];
string s,t;
void setNext(){
	next[0]=-1;
	int i=0,j=-1;
	while(i<s.length()){
		if(j==-1||s[i]==s[j]){
			i++;
			j++;
			next[i]=j;
		}else{
			j=next[j];
		}
	}
}

int main(){
	cin>>n>>k>>s;
	setNext();
	for(int i=0;i<n-next[n];i++){
		t+=s[i];
	}
	for(int i=1;i<=k-1;i++){
		cout<<t;
	}
	cout<<s;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <string>
#include<cstring>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e6+5;
const int Hash=131;
int Next[maxn];
string p;
void Next_pre()
{
    int len=(int)p.size();
    for(int i=1,j=0;i<len;i++){
        while (j&&p[i]!=p[j])j=Next[j-1];
        if(p[i]==p[j])j++;
        Next[i]=j;
    }
}

int main()
{
    int n,k;
        scanf("%d%d",&n,&k);
        p.clear();
        cin>>p;
        Next_pre();
        for(int i=0;i<Next[n-1];i++)
            cout<<p[i];
        for(int i=1;i<=k;i++)
            for(int j=Next[n-1];j<n;j++)
                cout<<p[j];
            printf("\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1000000;
char s[maxn];
int nxt[maxn],len,tot;

void getnext()
{
	nxt[0]=nxt[1]=0;
	for(int i=1;i<len;i++)
	{
		int j=nxt[i];
		while(j>0&&s[i]!=s[j]) j=nxt[j];
		if(s[i]==s[j]) nxt[i+1]=j+1;
		else nxt[i+1]=0;
	}

}

int main()
{
	scanf("%d%d",&len,&tot);
	scanf("%s",s);
	getnext();
	printf("%s",s);
	for(int i=1;i<tot;i++)
	for(int j=nxt[len];j<len;j++)
	printf("%c",s[j]);
}


#include<bits/stdc++.h>
#define mod 1e9+7
#define inf 0x3f3f3f
typedef long long ll;
typedef long double ld;
using namespace std;
int n,nxt[100],k;
char t[60];
void get_next(){
	nxt[0]=nxt[1]=0;
	int j=0;
	for(int i=1;i<n;i++){
		j=nxt[i];
		while(t[i+1]!=t[j+1]&&j>0)j=nxt[j];
		if(t[i+1]==t[j+1])nxt[i+1]=j+1;
		else nxt[i+1]=0;
		//cout<<i+1<<" "<<nxt[i+1]<<endl;
	}
}
int main(){
    scanf("%d%d",&n,&k);
    scanf("%s",t+1);
    get_next();
    for(int i=1;i<=n;i++){
    	printf("%c",t[i]);
    	if(i==n){
    		i=nxt[i];
    		k--;
		}
		if(k==0)break;
	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
char s1[1000001];
int l1,p[1000001],n,m;
void pre() {
	p[1]=0;
	int j=0;
	for(int i=1; i<n; i++) {
		while(j>0&&s1[j+1]!=s1[i+1])j=p[j];
		if(s1[j+1]==s1[i+1])j++;
		p[i+1]=j;
	}
	return;
}
int main() {
	cin>>n>>m>>s1+1;
	pre();
	for(int i=1; i<=m; i++) {
		for(int j=1; j<=n-p[n]; j++) {
			cout<<s1[j];
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	char t[100005];
	cin>>t;
	int maxsize=-1;//记录最多能给ka掉多少位
	for(int i=0;i<n-1;i++){
		bool flag=0;//插个旗子
		for(int j=0;j<=i;j++){
			if(t[j]!=t[n-i+j-1]){//我匹配我自己 如果匹配不上...
				flag=1;//...就拔掉旗子 然后break掉省时间
				break;
			}
		}
		if(!flag)maxsize=i;//如果旗子没被拔掉就记录下
	}
    maxsize++; //因为j<=i,所以当i=0时j其实会跑一次，i=1时跑两次，以此类推。既然这样那就要把跑的次数记到maxsize里边，也就是给它++下

	for(int i=1;i<k;i++){
		for(int j=0;j<n-maxsize;j++){//先少输出一遍
			cout<<t[j];
		}
	}
	cout<<t;//最后把完整的输出上
	return 0;
}


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

int n,k;
int p[55];
string t;

void getp()
{
    int j=0;
    p[0]=p[1]=0;
    for(int i=1;i<t.length();++i){
        while(j&&t[j]!=t[i])
            j=p[j];
        if(t[j]==t[i])
            j++;
        p[i+1]=j;
    }
}

void build()
{
    getp();
    string ans=t;
    int cnt=1;
    ///nums of matchings
    while(cnt<k){
        for(int i=p[t.length()];i<t.length();++i)
            ans.append(1,t[i]);
        cnt++;
    }
    cout<<ans;
}

int main()
{
    cin>>n>>k>>t;
    build();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
char a[55];
int main()
{
	scanf("%d %d\n",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%c",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]==a[n-1-i]&&i!=n-1-i)
		{
			ans++;
		}
		else break;
	}
	for(int i=0;i<n;i++)
	{
		printf("%c",a[i]);
	}
	for(int i=1;i<=k-1;i++)
	{
		if(ans==0)
		for(int i=0;i<n;i++)
		printf("%c",a[i]);
		else
		{
			for(int j=ans;j<n;j++)
	     	printf("%c",a[j]);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define N 100
using namespace std;
int next[N],n;
int KMP(char t[])
{
    int j = 0;
    for(int i = 2;i <= n;i++)
    {
        while(j && t[j+1] != t[i])
        {
            j = next[j];
        }
        if(t[i] == t[j+1])
        {
            j++;
        }
        next[i] = j;
    }
    return 0;
}
int main()
{
    char t[N];
    int k;
    cin >>n>>k;
    cin >> t+1;
    KMP(t);
    cout << t+1;
    for(int i = 1;i <= k-1;i++)
    {
        cout << t + 1 + next[n];
    }
    return 0；
}


#include<iostream>
#define MAXN 10000
using namespace std;

int kmp(int next[],int la,int lb,char b[],char a[]){
	int j=0,flag=0;
	for(int i=1;i<=la;i++){
		while(j>0&&a[i]!=b[j+1])
			j=next[j];
		if(a[i]==b[j+1])
			j++;
		if(j==lb)
			flag++;
	}
	return flag;
}

int main(){
	int n,k;
	cin>>n>>k;
	char t[n+2];
	cin>>t+1;
	int j=0;
	int next[n+2];
	next[1]=0;
	for(int i=2;i<=n;i++){
		while(j>0&&t[j+1]!=t[i])
			j=next[j];
		if(t[j+1]==t[i])
			j++;
		next[i]=j;
	}
//	for(int i=1;i<=n;i++){
//		cout<<next[i]<<" ";
//	}
	char s[MAXN];
	for(int i=1;i<=n;i++)
		s[i]=t[i];
	j=1;int i=1;
	int flag=0;
	while(kmp(next,j,n,t,s)<k){
		if(next[i]>0)
			i=next[i];
		s[j]=t[i];j++;i++;
		if(i>n)
			i=1;
		//cout<<kmp(next,j,n,t,s)<<endl;
	}
	for(i=1;i<=j;i++)
		cout<<s[i];
	return 0;
}


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

const int maxn = 2e5 + 10;

char s[maxn];
char p[maxn];
int ne[maxn];
int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    scanf("%s", p+1);
    for (int i = 2, j = 0; i <= n; ++i)
    {
        while (j && p[i] != p[j+1]) j = ne[j];
        if (p[i] == p[j+1]) ++j;
        ne[i] = j;
    }
    strcpy(s+1, p+1);
    for (int i = 1; i < k; ++i)
    {
        int j = ne[n];
        strcat(s+1, p+1+j);
    }
    printf("%s\n", s+1);
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int f[60],n,k;
char s[60];
void Cal_Next(){
	f[0]=f[1]=0;
	for(int i=1;i<n;i++){
		int j=f[i];
		while(j>0 && s[i]!=s[j])j=f[j];
		if(s[i]==s[j])f[i+1]=j+1;
		else f[i+1]=0;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	Cal_Next();
	printf("%s",s);
	for(int i=1;i<k;i++){
		for(int j=f[n];j<n;j++)printf("%c",s[j]);
	}
}


#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;
const int N=53;
char s[N],c[N];
int nex[N],l,k;
int main()
{
	scanf("%d %d",&l,&k);
	scanf("%s",s);
	nex[0]=-1;int j=-1;
	for(int i=1;i<=l;i++)
	{
		while(j!=-1 && s[i-1]!=s[j]) j=nex[j];
		nex[i]=++j;
	}
	printf("%s",s);
	j=0;
	for(int i=nex[l];i<l;i++) c[j++]=s[i];
	for(int j=1;j<k;j++) printf("%s",c);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int t;
int nex[10100];
char a[101001];
string ans;
int main(){
	cin>>n>>t;

	cin>>a+1;
	nex[1]=0;
	int k=0;
	for(int i=2;i<=n;i++){
		if(a[k+1]!=a[i]&&k!=0) k=nex[k];
		while(a[k+1]==a[i]) k++;
		nex[i]=k;
	}

	int z=n-nex[n];

	t--;
	for(int i=1;i<=n;i++){
		 cout<<a[i];
	}
	while(t--){
		for(int i=n-z+1;i<=n;i++){
			cout<<a[i];
		}
	}

}


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

int main()
{
	char t[60];
	int n, k;
	cin >> n >> k;
	scanf("%s", t);
	int lt = strlen(t);
	int *pre = new int[lt];
	pre[0] = -1;
	for (int i = 1, k = -1; i < lt; i++)
	{
		while (k >= 0 && t[k + 1] != t[i])k = pre[k];
		if (t[k + 1] == t[i])k++;
		pre[i] = k;
	}

	cout << t;
	for (int i = 2; i <= k; i++)
	{
		printf("%s", t + pre[lt - 1] + 1);
	}

	system("pause");
	return 0;
}


#include<cstdio>
using namespace std;
#define REP(i,j,k) for(int i=j;i<=k;i++)
char s[55]={};
int p[55]={};
int main(){
    int n,k;scanf("%d%d%s",&n,&k,s);
    int j=0;
    REP(i,1,n){
        while(j>0&&s[i]!=s[j]) j=p[j];
        if(s[i]==s[j]) j++;
        p[i+1]=j;
    }
    printf("%s",s);
    REP(i,2,k) REP(j,p[n],n-1) printf("%c",s[j]);
    printf("\n");
    return 0;
}