359 传统题

[ABC351B] 矩阵找茬 (Spot the Difference)

时间限制
2000ms
内存限制
1024MiB
登顶 / 尝试
0/ 0
难度
1
    上传者 标签AtCoderABC351入门二维数组模拟

[ABC351B] 矩阵找茬 (Spot the Difference)

Score: 150150 points

Problem Statement

You are given two grids, each with NN rows and NN columns, referred to as grid AA and grid BB.

Each cell in the grids contains a lowercase English letter.

The character at the ii-th row and jj-th column of grid AA is Ai,jA_{i, j}.

The character at the ii-th row and jj-th column of grid BB is Bi,jB_{i, j}.

The two grids differ in exactly one cell. That is, there exists exactly one pair (i,j)(i, j) of positive integers not greater than NN such that Ai,j≠Bi,jA_{i, j} \neq B_{i, j}. Find this (i,j)(i, j).

Constraints

  • 1≤N≤1001 \leq N \leq 100

  • Ai,jA_{i, j} and Bi,jB_{i, j} are all lowercase English letters.

  • There exists exactly one pair (i,j)(i, j) such that Ai,j≠Bi,jA_{i, j} \neq B_{i, j}.

Input

The input is given from Standard Input in the following format:

$N$
$A_{1,1}A_{1,2}\dots A_{1,N}$
$A_{2,1}A_{2,2}\dots A_{2,N}$
$\vdots$
$A_{N,1}A_{N,2}\dots A_{N,N}$
$B_{1,1}B_{1,2}\dots B_{1,N}$
$B_{2,1}B_{2,2}\dots B_{2,N}$
$\vdots$
$B_{N,1}B_{N,2}\dots B_{N,N}$

Output

Let (i,j)(i, j) be the pair of positive integers not greater than NN such that Ai,j≠Bi,jA_{i, j} \neq B_{i, j}. Print (i,j)(i, j) in the following format:

$i$ $j$

Sample Input 1

3
abc
def
ghi
abc
bef
ghi

Sample Output 1

2 1

From A2,1=A_{2, 1} = d and B2,1=B_{2, 1} = b, we have A2,1≠B2,1A_{2, 1} \neq B_{2, 1}, so (i,j)=(2,1)(i, j) = (2, 1) satisfies the condition in the problem statement.

Sample Input 2

1
f
q

Sample Output 2

1 1

Sample Input 3

10
eixfumagit
vtophbepfe
pxbfgsqcug
ugpugtsxzq
bvfhxyehfk
uqyfwtmglr
jaitenfqiq
acwvufpfvv
jhaddglpva
aacxsyqvoj
eixfumagit
vtophbepfe
pxbfgsqcug
ugpugtsxzq
bvfhxyehok
uqyfwtmglr
jaitenfqiq
acwvufpfvv
jhaddglpva
aacxsyqvoj

Sample Output 3

5 9