import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { //int t = f.nextInt();while(t-- > 0) solve(); out.close(); } static Node[][] nodes; static void solve() { int n = f.nextInt(); char c = f.next().charAt(0); nodes = new Node[n][n]; for(int i=0;i[] diag = new ArrayList[205]; for(int i=0;i<205;i++) { diag[i] = new ArrayList<>(); } for(int i=0;i(); } for(int i=0;i[] diag = new ArrayList[205]; for(int i=0;i<205;i++) { diag[i] = new ArrayList<>(); } for(int i=0;i(); } for(int i=0;i= 0 && nowI < n && nowJ >= 0 && nowJ < n && nodes[nowI][nowJ].c == c) { nodes[nowI][nowJ].adj.add(new int[] {i,j}); nodes[i][j].adj.add(new int[] {nowI,nowJ}); } } } } } } else { int[][] dir = {{0,1},{1,0},{1,1},{1,-1}}; for(int i=0;i= 0 && nowI < n && nowJ >= 0 && nowJ < n && nodes[nowI][nowJ].c == c) { nodes[nowI][nowJ].adj.add(new int[] {i,j}); nodes[i][j].adj.add(new int[] {nowI,nowJ}); } } } } } } int cnt = 0; int[] start = new int[2]; for(int i=0;i step = new ArrayList<>(); static void bfs(int[] now, int[] par) { if(!nodes[now[0]][now[1]].sd) { nodes[now[0]][now[1]].sd = true; } else { return; } for(int i=0;i adj = new ArrayList<>(); Node(char c) { this.c = c; } } static FastReader f = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static class FastReader { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; String next() { while(st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch(IOException ioe) { ioe.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } } }