#include <stdio.h>

#define MAX_SIZE 10

int main() {
    int N, M;
    int matrix_N[MAX_SIZE][MAX_SIZE];
    int matrix_M[MAX_SIZE][MAX_SIZE];
    int i, j, k, l;
    int flag, found;

    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            scanf("%d", &matrix_N[i][j]);
        }
    }

    scanf("%d", &M);
    for (i = 0; i < M; i++) {
        for (j = 0; j < M; j++) {
            scanf("%d", &matrix_M[i][j]);
        }
    }

    found = 0;
    for (i = 0; i <= N - M; i++) {
        for (j = 0; j <= N - M; j++) {
            flag = 1;
            for (k = 0; k < M; k++) {
                for (l = 0; l < M; l++) {
                    if (matrix_N[i + k][j + l] != matrix_M[k][l]) {
                        flag = 0;
                        break;
                    }
                }
                if (!flag) {
                    break;
                }
            }
            if (flag) {
                printf("%d,%d\n", i + 1, j + 1);
                found = 1;
                break;
            }
        }
        if (found) {
            break;
        }
    }

    if (!found) {
        printf("-1\n");
    }

    return 0;
}
