Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-elementni-qidirish

Find an element

Easy 1000 ms 128 MB 27%
Share

An integer matrix of size $n \times m$ and an integer $x$ are given. Find the row and column numbers of the first occurrence of $x$ in the matrix (numbering starts at $1$): the rows are scanned top to bottom, each row left to right.

Finding the first occurrence of an element in the matrix

Input

The first line contains $n$ and $m$. Each of the next $n$ lines contains $m$ integers. The last line contains an integer $x$.

Output

One line with two space-separated integers: the row number and the column number. If $x$ is not in the matrix, print a single number -1.

Note

$1 \le n, m \le 200$
$-1000 \le a_{i,j} \le 1000$
$-1000 \le x \le 1000$

Examples

Input #1
2 3
1 -2 3
-4 5 6
5
Output #1
2 2
Input #2
2 2
1 2
3 4
9
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.