n m // in the first line two numbers are written: n (n <= 1500),representing the number of crossings in the city; m (m <= 5000), representing the number of streets; i_{11} i_{12} // the next m lines contain pairs of two numbers, representing the identifiers of the crossings to which each street is connected. i_{21} i_{22} ... i_{m1} i_{m2}
p // on the first line the maximum number of policemen that can be sent "on the field" t_{11} t_{12} ... t_{1k1} t_{21} t_{22} ... t_{2k2} // in the next p lines, the routes given to the policemen will be written and for each route the crossings on it ... will be mentioned; the data in each line will be separated by a space. t_{p1} t_{p2} ... t_{pkp}
INPUT.TXT 7 10 1 2 1 6 2 6 2 3 3 4 3 5 3 6 4 5 5 6 5 7 OUTPUT.TXT 4 1 2 6 1 2 3 6 2 3 6 5 4 3 3 5 4 3
"Ion Luca Caragiale" High School, Ploiesti.

n // the number of stages; c_{1} c_{2} ... c_{r} // the characters of the alphabet, separated by space; i // the number of the initial stage; 1 <= i <= n; k_{1} k_{2} ... k_{l} s_{11} s_{12} ... s_{1i1} s_{21} s_{22} ... s_{2i2} ... s_{(n*r)1} s_{(n*r)2} ... s_{(n*r)i(n*r)} // in the following n*r lines the evolution function is described in the following way:  on the first n lines for c_{1} the evolution through the n stages, and so on  0 designates an empty set.
word_1 word_2 .... word_m
In the file CUVINTE.TXT there will be words containing only the allowed characters (the ones in DICTION.TXT).
DICTION.TXT: CUVINTE.TXT: 4 abb a b aabaa 1 aaab 3 4 bbb 2 3 4 abaa 0 4 3 1 3 2 4 0 1 LIMBAJ.TXT: YES YES NO YES YES
n_{1} n_{2} ... // n_{i} is the number of sides of the polygon n_{k}
p_{1} p_{2} ... // p_{i} is the number of crossings corresponding to the n_{i}sided polygon. p_{k}