#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
using namespace std;
const int maxn=20,max1=1<<12;
int p[maxn][max1],end;
vector<int>d[maxn],l[maxn];
struct node{
int num,ligh;
};
queue<struct node>q;
int main(){
int i,j,k,m,n;
scanf("%d%d%d",&n,&m,&k);
end=1<<n;
for(int i=1;i<=m;i++){
int x,y;
scanf("%d%d",&x,&y);
d[x].push_back(y);
d[y].push_back(x);
}
for(int i=1;i<=k;i++){
int a,b;
scanf("%d%d",&a,&b);
l[a].push_back(b);
}
q.push((struct node){1,2});
p[1][2]=1;
while(!q.empty()){
int u=q.front().num,v=q.front().ligh,z,h;
q.pop();
if(u==n && v==end){
printf("Mr. Black needs %d steps.\n",p[u][v]-1);
return 0;
}
for(int i=0;i<d[u].size();i++){
if(v&(1<<(z=d[u][i])) && !p[z][v]){
p[z][v]=p[u][v]+1;
q.push((struct node){z,v});
}
}
for(int i=0;i<l[u].size();i++){
if(!p[u][h=(v^(1<<l[u][i]))]){
p[u][h]=p[u][v]+1;
q.push((struct node){u,h});
}
}
}
puts("Poor Mr. Black! No sleep tonight!");
return 0;
}
各种神奇的位运算。。。。