B. North Pole Retirement
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Santa has gotten quite old and is entering retirement. To get ready, he'd like to practice playing some bingo.

Santa plays a special type of bingo on a $$$N \times N$$$ grid, where each cell contains a unique number between $$$1$$$ and $$$N^2$$$. Some permutations of these numbers are called out successively. When a full row or column is called out, Santa wins!

Given Santa's board and the order in which the numbers are called, determine which number Santa will win with.

Input

A single integer, $$$2 \leq N \leq 100$$$.

An $$$N \times N$$$ grid with numbers $$$1...N^2$$$, showing the board

The $$$N^2$$$ numbers, in the order they're called

Output

The number that will cause Santa to win

Example
Input
3
2 7 9
8 3 1
6 5 4
4 6 8 7 5 3 2 9 1
Output
5
Note

Note that the first row/column to fill up is the bottom row.