#include <stdio.h>
#include <stdlib.h>
char s[999][999];
int book[999];
int main()
{
int n,m,cnt=0,temp=0;
char c;
scanf ("%d %d %c",&n,&m,&c);
fflush(stdin);
int i,j;
for (i=0;i<n;i++){
for (j=0;j<m;j++){
scanf ("%c",&s[i][j]);
if (s[i][j]=='o') {
book[cnt]=i;
book[cnt+1]=j;
cnt+=2;
}
if (s[i][j]=='x'){
temp++;
}
}
fflush(stdin);
}
if (!temp||!cnt){
printf ("OK");
exit(0);
}
int flag=1;
switch (c){
case '^':
for (cnt;cnt>1;cnt-=2){
i=book[cnt-2];j=book[cnt-1];
while (i>=0){
if (s[i][j]=='x'){
flag=0; goto ans;
}
i--;
}
}
break;
case 'v':
for (cnt;cnt>1;cnt-=2){
i=book[cnt-2];j=book[cnt-1];
while (i<n){
if (s[i][j]=='x'){
flag=0; goto ans;
}
i++;
}
}
break;
case '<':
for (cnt;cnt>1;cnt-=2){
i=book[cnt-2];j=book[cnt-1];
while (j>=0){
if (s[i][j]=='x'){
flag=0; goto ans;
}
j--;
}
}
break;
case '>':
for (cnt;cnt>1;cnt-=2){
i=book[cnt-2];j=book[cnt-1];
while (j<m){
if (s[i][j]=='x'){
flag=0; goto ans;
}
j++;
}
}
break;
}
ans:
if (flag) printf ("OK");
else printf("GG");
system("pause");
return 0;
}