{
TASK:seq
LANG:Pascal
}
var
 n:byte;
 m,i,j,p,q,r:longint;
 a:array[1..120000] of longint;
 b:array[1..10] of byte;
procedure rd;
begin
 read(m);
 read(a[1]);
 for j:=2 to m do begin
                   read(a[j]);
                   if(a[j]<=a[1]) then break;
                  end;
 if(j=m)and(a[j]>a[1]) then begin
                             b[i]:=0;
                             exit;
                            end;
 q:=a[j-1];
 r:=a[j];
 for p:=j+1 to m do begin
                     read(a[p]);
                     if a[p]>q then q:=a[p]
                               else if a[p]>r then r:=a[p]
                                              else begin
                                                    b[i]:=0;
                                                    exit;
                                                   end;
                    end;
 b[i]:=1;
end;
begin
 readln(n);
 for i:=1 to n do rd;
 for i:=1 to n do write(b[i]);
 writeln;
end.
