int n,m,t;
int i,j,k;
char ch[10000+5];
int mp[30][30];
int main()
{
IOS;
while(~scanf("%s",ch)){
ms(mp,0);
getchar();
while(ch[0]!='0'){
int len=strlen(ch);
mp[ch[0]-'a'][ch[len-1]-'a']=1;
gets(ch);
}
for(int i=0;i<26;i++){
for(int k=0;k<26;k++){
if(mp[i][k]){
for(int j=0;j<=26;j++){
if(mp[k][j])
mp[i][j]=1;
}
}
}
}
puts(mp['b'-'a']['m'-'a'] ? "Yes.":"No.");
}
//PAUSE;
return 0;
}