Captain Bajtazar is overseeing the colonization of the resource-rich planetoid BA-1T. His duties include managing the ardanium-mining robots. The space weather forecast predicts a meteor shower is coming soon, and it would be best for all robots to hide in armored bases.
Unfortunately, the robot control system leaves much to be desired. The only thing that can be done is to enter a single non-negative integer $k$ into it, which will cause the command "Move!" to be sent to each robot $k$ times.
There are $n$ sectors designated on the planet's surface. Some of them are bases, and the others are open-pit ardanium mines. The mining robots are equipped with quantum brains and therefore act non-deterministically. For each sector $s$, Bajtazar knows a non-empty set of sectors $A_s$ such that any robot located in sector $s$ will move to one of the sectors in the set $A_s$ after receiving the command. However, it is not known exactly which one; one cannot count on any repeatability – even if a robot is in sector $s$ for the $n$-th time in a row, it may move to a different sector this time than it did previously.
Now Bajtazar is wondering if there exists a $k$ such that every robot will definitely be in one of the bases after executing the "Move!" command $k$ times.
Input
The first line of input contains three integers $n$, $b$, and $r$ ($2 \le n \le 200$, $1 \le b, r \le n$), representing the number of sectors, the number of bases, and the number of mining robots, respectively. The sectors are numbered from $1$ to $n$, where those numbered from $1$ to $b$ are bases.
This is followed by $n$ lines containing descriptions of possible transitions after the "Move!" command. The $i$-th of these lines contains a string of $n$ digits from the set $\{0, 1\}$; the $j$-th digit is $1$ if and only if a miner can move from sector $i$ to sector $j$ after receiving the command. At least one digit in each row is $1$.
The last line of input contains an increasing sequence of $r$ numbers from the range $1$ to $n$, representing the sector numbers where the robots are initially located.
Output
If the number $k$ sought by Bajtazar does not exist, output $-1$. Otherwise, it is guaranteed that there exists a non-negative integer satisfying Bajtazar's requirements that has at most $200$ digits (in decimal notation). In that case, output any such number.
Examples
Input 1
4 2 2 0100 0010 1001 1000 3 4
Output 1
2
Input 2
4 2 2 0100 0010 1001 1000 2 3
Output 2
-1