var i,j,k,n,u,v:longint;
    p:array[0..120000] of integer;
procedure prehod(x,y,z:integer);
var t:integer;
begin
  t:=p[z];
  p[z]:=p[y];
  p[y]:=p[x];
  p[x]:=t;
end;
begin
  read(n);
  while  n<>0 do
  begin
    j:=0;
    u:=1;
    for i:=1 to n do 
    begin
      read(p[i]);
      if p[i]=i then p[i]:=-1;
    end;
    for i:=1 to n-2 do
    begin
{     
      for j:=1 to n do write(p[j],' ');
      writeln;
}      
      while (p[u]=-1) and (u<=n) do inc(u);
      if u>n then break;
      j:=u+1;
      k:=p[u];
      while ((p[j]=-1) and (j<=n)) or (j=k) do inc(j);
      if j>n then break;
{      writeln(u,' ',k,' ',j);}
      prehod(u,k,j);
{      writeln('p:',p[k],' ',k,' ',p[u],' ',u,' ',p[j],' ',j);}
      p[k]:=-1;
      if p[u]=u then p[u]:=-1;
      if p[j]=j then p[j]:=-1;
    end;
{     
      for j:=1 to n do write(p[j],' ');
      writeln;
}      
    j:=0;
    for i:=1 to n do if p[i]<>-1 then
    begin
      j:=1;
      break;
    end;
    if j=1 then writeln('Matfyzacci maji smulu.') else writeln('Permutaci lze prevest.');
    read(n);
  end;
end.
