/*
TASK:seq
LANG:C++
*/
#include <iostream>
using namespace std;
int main()
{
    int n,i,t,m;
    int a[10][9999],b[9999],c[9999],u[10];
    cin >> n;
    for (i=0; i<n; i++)
    {
        cin >> m;
        for (t=0;t<m;t++)
        cin >> a[i][t];
    }
    for (i=0;i<n;i++)
    {
      b[0]=a[i][0];
      c[0]=a[i][1];
      int b1=0;
      int c1=0;
      for (t=2;t<m;t++)
      {  if (t==(m-1)) u[i]=1;
         if (a[i][t]>=b[b1]) {b[b1+1]=a[i][t];b1=b1+1;}
         else if (a[i][t]>=c[c1]) {c[c1+1]=a[i][t];c1=c1+1;}
         else {u[i]=0;}
          
      }
    }
    for (i=0;i<n;i++)
    {cout << u[i];}
    int x;
    cout << "x=";
    cin >> x;
return 0;
}
