import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt(), M = input.nextInt();
char[][] map = new char[N][M];
input.nextLine();
//store the map data
for (int i = 0; i < N; i++) {
map[i] = input.nextLine().toCharArray();
}
//store the sA -- surroundingArea
char[][] sA = new char[3][3];
for (int i = 0; i < 3; i++) {
sA[i] = input.nextLine().toCharArray();
}
//print the possible positions
printPossiblePositions(map, sA);
input.close();
}
private static void printPossiblePositions(char[][] map, char[][] sA) {
for (int j = 1; j < map.length - 1; j++) {
for (int i = 1; i < map[j].length - 1; i++) {
if (sA[1][1] == map[i][j]) {
boolean found;
//1
found = true;
for (int xSA = 0, xMap = i-1; xSA < 3; xSA++, xMap++) {
for (int ySA = 0, yMap = j-1; ySA < 3; ySA++, yMap++) {
if (sA[xSA][ySA] != map[xMap][yMap] ) {
found = false;
break;
}
}
if (found == false) {
break;
}
}
if (found == true) {
System.out.println((i+1) + " " + (j+1));
break;
}
//2
found = true;
for (int ySA = 2, xMap = i-1; ySA >= 0; ySA--, xMap++) {
for (int xSA = 0, yMap = j-1; xSA < 3; xSA++, yMap++) {
if (sA[xSA][ySA] != map[xMap][yMap] ) {
found = false;
break;
}
}
if (found == false) {
break;
}
}
if (found == true) {
System.out.println((i+1) + " " + (j+1));
break;
}
//3
found = true;
for (int xSA = 2, xMap = i-1; xSA >= 0; xSA--, xMap++) {
for (int ySA = 2, yMap = j-1; ySA >= 0; ySA--, yMap++) {
if (sA[xSA][ySA] != map[xMap][yMap] ) {
found = false;
break;
}
}
if (found == false) {
break;
}
}
if (found == true) {
System.out.println((i+1) + " " + (j+1));
break;
}
//4
found = true;
for (int ySA = 0, xMap = i-1; ySA < 3; ySA++, xMap++) {
for (int xSA = 2, yMap = j-1; xSA >= 0; xSA--, yMap++) {
if (sA[xSA][ySA] != map[xMap][yMap] ) {
found = false;
break;
}
}
if (found == false) {
break;
}
}
if (found == true) {
System.out.println((i+1) + " " + (j+1));
break;
}
}
}
}
}
}