#include <bits/stdc++.h>
using namespace std;
int dd[110][110];
char a[110][110];
int n;
int main()
{
cin>>n;
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++) cin>>a[i][j];
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (a[i][j]=='I' && a[p][q]=='C' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=1;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==1 && a[p][q]=='P' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=2;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==2 && a[p][q]=='C' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=3;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==3 && a[p][q]=='A' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=4;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==4 && a[p][q]=='S' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=5;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==5 && a[p][q]=='I' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=6;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==6 && a[p][q]=='A' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=7;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==7 && a[p][q]=='S' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=8;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==8 && a[p][q]=='G' && ((i-p)*(i-p)+(j-q)*(j-q)==5)) dd[p][q]=9;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
for (int p=1;p<=n;p++)
for (int q=1;q<=n;q++)
if (dd[i][j]==9){
cout<<"YES";
return 0;
}
}
cout<<"NO";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgZGRbMTEwXVsxMTBdOwpjaGFyIGFbMTEwXVsxMTBdOwppbnQgbjsKaW50IG1haW4oKQp7CiAgICBjaW4+Pm47CiAgICBmb3IgKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIGZvciAoaW50IGo9MTtqPD1uO2orKykgY2luPj5hW2ldW2pdOwogICAgfQogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBmb3IgKGludCBqPTE7ajw9bjtqKyspCiAgICAgICAgICAgIGZvciAoaW50IHA9MTtwPD1uO3ArKykKICAgICAgICAgICAgICAgIGZvciAoaW50IHE9MTtxPD1uO3ErKykKICAgICAgICAgICAgICAgICAgICBpZiAoYVtpXVtqXT09J0knICYmIGFbcF1bcV09PSdDJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT0xOwogICAgfQogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBmb3IgKGludCBqPTE7ajw9bjtqKyspCiAgICAgICAgICAgIGZvciAoaW50IHA9MTtwPD1uO3ArKykKICAgICAgICAgICAgICAgIGZvciAoaW50IHE9MTtxPD1uO3ErKykKICAgICAgICAgICAgICAgICAgICBpZiAoZGRbaV1bal09PTEgJiYgYVtwXVtxXT09J1AnICYmICgoaS1wKSooaS1wKSsoai1xKSooai1xKT09NSkpIGRkW3BdW3FdPTI7CiAgICB9CiAgICBmb3IgKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIGZvciAoaW50IGo9MTtqPD1uO2orKykKICAgICAgICAgICAgZm9yIChpbnQgcD0xO3A8PW47cCsrKQogICAgICAgICAgICAgICAgZm9yIChpbnQgcT0xO3E8PW47cSsrKQogICAgICAgICAgICAgICAgICAgIGlmIChkZFtpXVtqXT09MiAmJiBhW3BdW3FdPT0nQycgJiYgKChpLXApKihpLXApKyhqLXEpKihqLXEpPT01KSkgZGRbcF1bcV09MzsKICAgIH0KICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKQogICAgICAgICAgICBmb3IgKGludCBwPTE7cDw9bjtwKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBxPTE7cTw9bjtxKyspCiAgICAgICAgICAgICAgICAgICAgaWYgKGRkW2ldW2pdPT0zICYmIGFbcF1bcV09PSdBJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT00OwogICAgfQoKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKQogICAgICAgICAgICBmb3IgKGludCBwPTE7cDw9bjtwKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBxPTE7cTw9bjtxKyspCiAgICAgICAgICAgICAgICAgICAgaWYgKGRkW2ldW2pdPT00ICYmIGFbcF1bcV09PSdTJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT01OwogICAgfQoKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKQogICAgICAgICAgICBmb3IgKGludCBwPTE7cDw9bjtwKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBxPTE7cTw9bjtxKyspCiAgICAgICAgICAgICAgICAgICAgaWYgKGRkW2ldW2pdPT01ICYmIGFbcF1bcV09PSdJJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT02OwogICAgfQoKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKQogICAgICAgICAgICBmb3IgKGludCBwPTE7cDw9bjtwKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBxPTE7cTw9bjtxKyspCiAgICAgICAgICAgICAgICAgICAgaWYgKGRkW2ldW2pdPT02ICYmIGFbcF1bcV09PSdBJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT03OwogICAgfQoKICAgIGZvciAoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgZm9yIChpbnQgaj0xO2o8PW47aisrKQogICAgICAgICAgICBmb3IgKGludCBwPTE7cDw9bjtwKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBxPTE7cTw9bjtxKyspCiAgICAgICAgICAgICAgICAgICAgaWYgKGRkW2ldW2pdPT03ICYmIGFbcF1bcV09PSdTJyAmJiAoKGktcCkqKGktcCkrKGotcSkqKGotcSk9PTUpKSBkZFtwXVtxXT04OwogICAgfQogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBmb3IgKGludCBqPTE7ajw9bjtqKyspCiAgICAgICAgICAgIGZvciAoaW50IHA9MTtwPD1uO3ArKykKICAgICAgICAgICAgICAgIGZvciAoaW50IHE9MTtxPD1uO3ErKykKICAgICAgICAgICAgICAgICAgICBpZiAoZGRbaV1bal09PTggJiYgYVtwXVtxXT09J0cnICYmICgoaS1wKSooaS1wKSsoai1xKSooai1xKT09NSkpIGRkW3BdW3FdPTk7CiAgICB9CgogICAgZm9yIChpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBmb3IgKGludCBqPTE7ajw9bjtqKyspCiAgICAgICAgICAgIGZvciAoaW50IHA9MTtwPD1uO3ArKykKICAgICAgICAgICAgICAgIGZvciAoaW50IHE9MTtxPD1uO3ErKykKICAgICAgICAgICAgICAgICAgICBpZiAoZGRbaV1bal09PTkpewogICAgICAgICAgICAgICAgICAgICAgICBjb3V0PDwiWUVTIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgfQogICAgY291dDw8Ik5PIjsKICAgIHJldHVybiAwOwp9