// Arup Guha
// 5/16/2016
// Solution to USACO 2016 April Bronze Problem: Bull in a China Shop

import java.util.*;
import java.io.*;

public class bcs {

	public static int n;
	public static int numPieces;
	public static boolean[][] art;
	public static boolean[][][] pieceArray;

	public static void main(String[] args) throws Exception {

		// Read in data.
		BufferedReader stdin = new BufferedReader(new FileReader("bcs.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		numPieces = Integer.parseInt(tok.nextToken());
		art = new boolean[n][n];

		int origOn = 0;

		// This is the original art work.
		for (int i=0; i<n; i++) {
			String tmp = stdin.readLine();
			for (int j=0; j<n; j++) {
 				art[i][j] = (tmp.charAt(j) == '#');
				if (art[i][j]) origOn++;
			}
		}

		int[] pieceOn = new int[numPieces];

		// Here are the potential pieces.
		pieceArray = new boolean[numPieces][n][n];
		for (int loop=0; loop<numPieces; loop++) {
			for (int i=0; i<n; i++) {
				String tmp = stdin.readLine();
				for (int j=0; j<n; j++) {
					pieceArray[loop][i][j] = (tmp.charAt(j) == '#');
					if (pieceArray[loop][i][j]) pieceOn[loop]++;
				}
			}
		}

		int result = -1;

		// Try each piece as the top left corner.
		for (int i=0; i<numPieces; i++) {

			// See if this piece fits in the top left.
			boolean[][] left = sub(art, pieceArray[i]);
			if (left == null) continue;

			boolean found = false;

			// Try to see if another piece matches what's left.
			for (int j=0; j<numPieces; j++) {
				if (j == i || origOn != pieceOn[i]+pieceOn[j]) continue;

				// Just use our subtract function again!
				boolean[][] res = sub(left, pieceArray[j]);
				if (res == null) continue;

				// Our result must be a blank canvas.
				if (isFalse(res)) {
					found = true;
					result = i < j ? numPieces*i+j : numPieces*j+i;
					break;
				}
			}

			// Found it!
			if (found) break;
		}

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("bcs.out"));
		out.println( (result/numPieces+1)+" "+(result%numPieces+1) );
		out.close();
		stdin.close();
	}

	// Returns the subtraction of piece from orig when lining up their top left-hand
	// corners, iff piece is a subset of orig in this offset. Otherwise, null is returned.
	public static boolean[][] sub(boolean[][] orig, boolean[][] piece) {

		int[] origLoc = getTopLeft(orig);
		int[] pieceLoc = getTopLeft(piece);

		// Will store result here, just make a copy of the original piece.
		boolean[][] result = new boolean[n][];
		for (int i=0; i<n; i++)
			result[i] = Arrays.copyOf(orig[i], n);

		// Try each part of piece.
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {

				int checkX = i-pieceLoc[0]+origLoc[0];
				int checkY = j-pieceLoc[1]+origLoc[1];

				// Catches an out of bounds piece.
				if (piece[i][j] && !inbounds(checkX, checkY))
					return null;

				// Can't be on in piece but not orig.
				if (piece[i][j] && !orig[checkX][checkY])
					return null;

				// Sub it out.
				if (piece[i][j]) result[checkX][checkY] = false;
			}
		}

		return result;
	}

	public static int[] getTopLeft(boolean[][] piece) {

		int[] res = new int[2];

		// Look for first match in row-col order.
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (piece[i][j]) {
					res[0] = i;
					res[1] = j;
					return res;
				}
			}
		}

		// Just for empty piece case.
		return res;
	}

	// Returns true iff all piece[i][j] is false.
	public static boolean isFalse(boolean[][] piece) {
		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				if (piece[i][j])
					return false;

		return true;
	}

	public static boolean inbounds(int x, int y) {
		return x >= 0 && x < n && y >=0 && y < n;
	}
}