//Это можно стереть. Если в N есть 0 то тогда программа выведет NO.program z1;var b,c,d,i,s,l:integer; a:string;beginread(a);b:=length(a);s:=StrToInt(a);c:=0;for i:=1 to b do for i:=1 to b do begin d:=StrToInt(a[i]); if d=0 then l:=1; end;if l=0 then begin for i:=1 to b do for i:=1 to b do begin d:=StrToInt(a[i]); if (s mod d)=0 then c:=c+1; end; end else write('NO');if (l=0) and (c=b) then write('T');if (l=0) and (c<>b) then write('P');end.