Robots

아직 제출이 없습니다시간 제한10초메모리 제한256 MB

문제

Captain Byteasar supervises the colonization of a natural asteroid BA-1T which is rich in raw materials. His job is controlling the robot-miners extracting ardanium. The space weather forecast predicts a meteor shower, and it would be better if all the robots were hidden in armoured strongholds once the shower happens.

Unfortunately, the miners control system leaves much to be desired. The only thing one can do is to input a single non-negative integer kk into it, which will result in sending kk "Move up!" commands to every robot.

There are nn sectors marked out on the surface of the planet. Some of the sectors are the strongholds, and the other ones are the open pit ardanium mines. Robot-miners are equipped with quantum brains and therefore they work nondeterministically. For each sector ss, Byteasar knows a non-empty set A_sA\_s, such that any robot located in the sector ss will move to one of the sectors of A_sA\_s after receiving a command. It is generally not known which sector of A_sA\_s will be picked; one can neither count on any repeatability -- even if a certain robot has been in the sector ss a few times already, next time it can move to a sector completely different than before.

Now Byteasar wonders whether there exists such kk, that after issuing kk "Move up!" commands, each robot will be in one of the strongholds for sure.

입력

The first line of the input contains three integers nn, bb and rr (2n2002 \le n \le 200, 1b,rn{1 \le b, r \le n}), denoting the number of sectors, the number of strongholds and the number of robot-miners, respectively. The sectors are numbered 11 through nn and the sectors numbered 11 through bb are the strongholds.

This is then followed by nn lines containing descriptions of possible transitions after receiving the "Move up!" command. The ii-th of these lines contains a string of nn digits from the set {0, 1}; the jj-th of these numbers is equal to 1 if and only if a miner can move from sector ii to sector jj after receiving a command. At least one digit in a line is equal to 1.

The last line of the input contains an increasing sequence of rr numbers ranging from 11 to nn, indicating the sectors where the robot-miners are initially present.

출력

In case a number kk, sought by Byteasar, does not exist, you should output the number 1-1. Otherwise we guarantee that there exists a non-negative integer satisfying Byteasar's requirements and having at most 200 digits (in decimal notation). Then, you should output any such number.