//Jackson Simoneau
//COP 3503H - Fall 2026
//K2: Knight Search

import java.util.*;
public class knightsearch {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String g = input.next();

        //stores the target string
        final String t = "ICPCASIASG";

        //add locations that have I to the queue
        Queue<Pair> q = new LinkedList<>();
        for(int i = 0; i < n*n; i++) {
            if(g.charAt(i) == t.charAt(0)) q.offer(new Pair(i, 0));
        }

        //run a BFS to find the target string
        while(!q.isEmpty()) {
            Pair p = q.poll();
            //check if end of the target string is reached
            if(p.ind == t.length()-1) {
                System.out.println("YES");
                return;
            }

            //move in all valid directions
            for(int dx = -2; dx <= 2; dx++) {
                for(int dy = -2; dy <= 2; dy++) {
                    if(Math.abs(dx) + Math.abs(dy) != 3) continue;
                    int newLoc = p.loc + n*dx + dy;
                    if(newLoc < 0 || newLoc >= n*n) continue;

                    //if the next character is found, add it to the queue
                    if(g.charAt(newLoc) == t.charAt(p.ind+1)) {
                        q.offer(new Pair(newLoc, p.ind+1));
                    }
                }
            }
        }

        //if we get here, the string cannot be formed
        System.out.println("NO");
    }
}

//stores pair of (location in grid, index in target string)
class Pair {
    int loc, ind;
    Pair(int loc, int ind) {
        this.loc = loc;
        this.ind = ind;
    }
}