#include<bits/stdc++.h>
using namespace std;
#define N 10
typedef struct PATH
{
int m;//地图数组的行下标
int n;//地图数组的列下标
PATH *next;
PATH *prev;
}PA;
PA *add(PA *head,int i,int j)//增加一个节点 记录AI的轨迹
{
PA *p,*pr=head;
p=(PA *)malloc(sizeof(PA));
if(p == NULL)
{
printf("Failed!\n");
exit(0);
}
if(head == NULL)
{
head=p;
}
else
{
while(pr->next!=NULL)
{
pr=pr->next;
}
pr->next=p;
p->prev=pr;
p->next=NULL;
}
p->m=i;
p->n=j;
return head;
}
PA *dl(PA *head,int *i,int *j)//碰壁 AI开始往回走 删除原先已建立节点 另寻他路
{
PA *pr=head,*p=NULL;
while(pr->next!=NULL)
{
pr=pr->next;
}
p=pr;
pr=pr->prev;
free(p);
pr->next=NULL;
*i=pr->m;
*j=pr->n;
return head;
}
int main()
{
char c;
int maze[N][N];
int i,j;
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
scanf(" %c",&c);
if(c=='.')
{
maze[i][j]=0;
}
else
{
maze[i][j]=1;
}
}
}
i=0;j=0;//i代表行 j代表列
PA *head;
head=(PA*)malloc(sizeof(PA));
head->m=i;
head->n=j;
head->prev=NULL;
head->next=NULL;
while(i!=9 && j!=9)
{
if(maze[i][j+1]==0)//右移
{
j++;
add(head,i,j);
maze[i][j]=1;
}
else if(maze[i+1][j]==0)//下移
{
i++;
add(head,i,j);
maze[i][j]=1;
}
else if(maze[i][j-1]==0)//左移
{
j--;
add(head,i,j);
maze[i][j]=1;
}
else if(maze[i-1][j]==0)//上移
{
i--;
add(head,i,j);
maze[i][j]=1;
}
else if(maze[i+1][j]==1 && maze[i-1][j]==1 && maze[i][j+1]==1 && maze[i][j-1]==1)//回退另寻他路
{
dl(head,&i,&j);
}
else if(maze[i][j]==2)
{
printf("No");
return 0;
}
}
printf("Yes\n");
return 0;
}