#include <iostream>
#include <fstream>
using namespace std;
int i,j,k,l,n,m;
bool a[15][85][85];
int f[100];
int head,tail,w[1000000];
int p,t;
int main()
{
ifstream fin("house.in");
ofstream fout("house.out");
fin>>n>>m>>t;
for (i=1;i<=t;i++)
for (j=1;j<=m;j++)
{
fin>>k>>l;
a[i][k][l]=1;
a[i][l][k]=1;
}
for (i=0;i<=n;i++)
f[i]=9999999;
head=1;
tail=1;
w[1]=1;
f[1]=0;
while (head<=tail)
{
for (i=1;i<=t;i++)
for (j=0;j<=n;j++)
{
p=(f[w[head]]+i)%t;
if (p==0)
p=t;
if (a[p][w[head]][j])
if (f[w[head]]+i<f[j])
{
tail++;
w[tail]=j;
f[j]=f[w[head]]+i;
}
}
head++;
}
if (f[0]==9999999)
fout<<"Poor Z4!\n";
else
fout<<f[0]<<endl;
fin.close();
fout.close();
return 0;
}