// Arup Guha
// 8/13/2026
// Solution to Kattis Problem: Knight Search
// https://open.kattis.com/problems/knightsearch

import java.util.*;

public class knightsearch {

	final public static int[] DR = {-2,-2,-1,-1,1,1,2,2};
	final public static int[] DC = {-1,1,-2,2,-2,2,-1,1};
	
	final public static String GOAL = "ICPCASIASG";
	
	public static int n;
	public static char[][] g;
	
	public static void main(String[] args) {
		
		// Read input.
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		char[] tmp = stdin.next().toCharArray();
		
		// Copy over grid into 2D form.
		g = new char[n][n];
		for (int i=0; i<n*n; i++)
			g[i/n][i%n] = tmp[i];
			
		// Try starting from each square.
		boolean res = false;
		for (int i=0; i<n*n; i++) {
			if (go(i/n, i%n, 0)) {
				res = true;
				break;
			}
		}
		
		// Ta da!
		if (res)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	
	public static boolean go(int r, int c, int k) {
	
		// We made it!
		if (k == GOAL.length()) return true;
		
		// Oops, out of bounds!
		if (r<0 || r>=n || c<0 || c>=n) return false;
		
		// Wrong letter.
		if (g[r][c] != GOAL.charAt(k)) return false;
		
		// Try each direction; return true if we found a way that works.
		for (int i=0; i<DR.length; i++) {
			boolean tmp = go(r+DR[i], c+DC[i], k+1);
			if (tmp) return true;
		}
		
		// Nothing worked :(
		return false;
	}
}