import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
static boolean result = false;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n = 0, m = 0;
if (cin.hasNext()) {
n = cin.nextInt();
m = cin.nextInt();
}
String target = cin.next();
char arrs[][] = new char[n][m];
int i = 0;
while (cin.hasNext()) {
String temp = cin.next();
for (int j = 0; j < temp.length(); j++) {
arrs[j] = temp.charAt(j);
}
i++;
if (i == n)
break;
}
char first = target.charAt(0);
for (i = 0; i < arrs.length; i++) {
for (int j = 0; j < arrs.length; j++) {
if (arrs[j] == first) {
HashSet set = new HashSet();
find(arrs, n, m, i, j, target, set);
if (result)
break;
}
}
}
}
private static void find(char[][] arrs, int n, int m, int i, int j,
String target, HashSet hashSet) {
// TODO Auto-generated method stub
char first = target.charAt(0);
if (arrs[j] != first) {
return;
}
if (hashSet.contains(i + j)) {
return;
}
if (target.length() == 1) {
System.out.println("YES");
result = true;
return;
}
hashSet.add(i + j);
target = target.substring(1);
for (int len = 0; len < 4; len++) {
HashSet temp = new HashSet(hashSet);
switch (len) {
case 0:
if (i > 0)
find(arrs, n, m, i - 1, j, target, temp);
else
return;
break;
case 1:
if (i < n - 1)
find(arrs, n, m, i + 1, j, target, temp);
else
return;
break;
case 2:
if (j > 0)
find(arrs, n, m, i, j - 1, target, temp);
else
return;
break;
case 3:
if (j < m - 1)
find(arrs, n, m, i, j + 1, target, temp);
else
return;
break;
default:
break;
}
}
}
}