Limits 500ms, 512 MB

The soldiers are being trained to fight against the Coronavirus. Mr. Hablu will shake hands with some soldiers there. So all the soldiers were placed on an $n \times n$ size grid. After talking to them, Mr. Hablu decided to shake hands with $X$ soldiers. But sadly, some of those soldiers may have the Coronavirus in their body, so that virus can infect Mr. Hablu and even those with whom he shakes hands afterwards.

You will be given a 2D grid of size $n \times n$ where healthy soldiers will be marked by $a$ and infected soldiers will be marked by $c$. In the next line you will be given a positive integer $X$ which will indicate the total number of soldiers and at the last line will contain ID numbers of the soldier with whom Mr. Hablu will shake hands.

Input

In the first line of input you will be given an integer $n \Big(1 \leq n \leq 500 \Big)$ and in the next line the input will contain a grid of size $n \times n$.

Then you will be given an integer $X \Big(1 \leq X \leq n^2 \Big)$ and the next line will contain $X$ positive integers.

Output

If Mr.Hablu is will get infected then you need to print “YES” otherwise print “NO”.

If the output is “YES” then in the next line you need to print the ID numbers of the soldiers who will get infected by shaking hands with Mr. Hablu.

Samples

InputOutput
5
aaaaa
accaa
acaaa
accaa
acaac
5
1 2 6 13 16
NO
InputOutput
5
aaaaa
accaa
acaaa
accaa
acaac
5
1 5 7 4 19
YES
4 19

Submit

Login to submit.

Statistics

78% Solution Ratio
EgorKulikovEarliest, Apr '20
theunownFastest, 0.0s
agtxdyLightest, 131 kB
shantolShortest, 194B
Toph uses cookies. By continuing you agree to our Cookie Policy.