One day, Yayun found a treasure map and started to look for the treasure.
But when she reached the goal marked on the map, there's another treasure map.
When Yayun was confused, an odd man walked over and told her:
"There are k maps in the world, each (ith) map points to the next (i+1th) map. You can find out the treasure locattion if you get the last (kth) map."
Please help Yayun to find the treasure.
Hint: You must find 1st, 2nd, ... k-1th, kth maps in order.
The first line contains a integer k, representing the number of maps you must find.
The second line contains two integer n, m representing the height and width of the map.
The next n lines, each line contains m integers.
For all testcases:
(2/6): no -1 on the map, k = 1, 1 <= n, m <= 200
(1/6): k = 1, 1 <= n, m <= 200
(1/6): no -1 on the map, 1 <= k <= 100, 1 <= n, m <= 200
(1/6): 1 <= k <= 100, 1 <= n, m <= 200
(1/6): 1 <= k <= 100, 1 <= n, m <= 200
The minimum steps to find the kth map.
If you cannot find the kth map, output -1.