## bzoj 1433 二分图匹配

/**************************************************************
Problem: 1433
Language: Pascal
Result: Accepted
Time:84 ms
Memory:268 kb
****************************************************************/

var
t, n, m                 :longint;
i                       :longint;
size                    :array[0..100] of longint;
know                    :array[0..100,0..100] of longint;
flag, bed               :array[0..100] of boolean;

function find(x:longint):boolean;
var
i                       :longint;
begin
for i:=1 to n do
if know[x,i]=1 then
if (not flag[i]) and (bed[i]) then
begin
flag[i]:=true;
begin
exit(true);
end;
end;
exit(false);
end;

procedure main;
var
i, j                    :longint;
x                       :longint;
ans, sum                :longint;
begin
fillchar(size,sizeof(size),0);
fillchar(know,sizeof(know),0);
fillchar(bed,sizeof(bed),false);
for i:=1 to n do read(size[i]);
for i:=1 to n do if size[i]=1 then bed[i]:=true;
for i:=1 to n do
begin
if (size[i]=1) and (x=0) then size[i]:=0;
end;
for i:=1 to n do
for j:=1 to n do read(know[i,j]);
for i:=1 to n do know[i,i]:=1;
ans:=0; sum:=0;
for i:=1 to n do if size[i]=0 then inc(sum);
for i:=1 to n do
if size[i]=0 then
begin
fillchar(flag,sizeof(flag),false);
if find(i) then inc(ans);
end;
if sum=ans then writeln('^_^') else writeln('T_T');
end;

begin
end.