public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            scanner.nextLine();
            String word = scanner.nextLine();
            char[][] matrix = new char[n][m];
            for (int i = 0; i < n; i++) {
                matrix[i] = scanner.nextLine().toCharArray();
            }
            boolean result = false;

            for (int i = 0; i < n && !result; i++) {
                for (int j = 0; j < m && !result; j++) {
                    boolean[][] visited = new boolean[n][m];
                    result = visit(word, matrix, visited, i, j);

                }
            }
            System.out.println(result ? "YES" : "NO");
        }


    }