program order; {$APPTYPE CONSOLE} var a:array[0..1048576] of integer; b:array[-3..100] of integer; s,i1,j1,j,k,i,n,m:integer; c:array[1..100] of char; begin assign(input,'order.DAT'); reset(input); assign(output,'order.SOL'); rewrite(output); readln(n); k:=0; for i:=1 to n do begin read(m); for j:=1 to m do read(a[j]); s:=0; for i1:=1 to m-1 do for j1:=i1+1 to m do if a[i1]>a[j1] then s:=s+1; k:=k+1; b[k]:=s mod 2; end; i:=k; j:=0; while i>0 do begin s:=b[i]+b[i-1]*10+b[i-2]*100+b[i-3]*1000; j:=j+1; case s of 0:c[j]:='0'; 1:c[j]:='1'; 10:c[j]:='2'; 11:c[j]:='3'; 100:c[j]:='4'; 101:c[j]:='5'; 110:c[j]:='6'; 111:c[j]:='7'; 1000:c[j]:='8'; 1001:c[j]:='9'; 1010:c[j]:='A'; 1011:c[j]:='B'; 1100:c[j]:='C'; 1101:c[j]:='D'; 1110:c[j]:='E'; 1111:c[j]:='F'; end; i:=i-4; end; i:=j; while c[i]='0' do i:=i-1; for j:=i downto 1 do write(c[j]); writeln; close(input); close(output); end.