|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||256 MB||0||0||0||0.000%|
There is a small Kingdom on Mars. There are some cities in the Kingdom, some of them are regional enters. The Kingdom has also a capital which may be a regional enter or not. Cities are conneted with one-way roads. Some of the roads are red and the remaining ones are blue. There is no more than one road of each color getting out of each city.
There is a tradition that the King goes to a trip each year. The trip starts from the capital city and consists of L roads. The trip must end in some regional enter. In historial-aesthetic purposes, the sequence of colors of visited roads is written in Chronicles. The red road is denoted by character `0', and the blue road is denoted by `1', so the result is a sequence of L binary digits.
Young Martian Vasja studies history. Recently he found some parts of Chronicles describing the period of ruling of the King Ares. Vasja discovered the following requirement that should have been satisfied by the King. Each year the King must choose a new route, the sequence of whih is greater than the corresponding one for previous year. When comparing, sequences are interpreted as binary numbers with leading zeros allowed. In the first year of his ruling the King was allowed to choose any route he wished. If the King is unable to find the route, he must finish his ruling. Vasja also discovered that Ares was very smart and he always chose such routes that maximized the length of his ruling period.
Since Vasja has only parts of Chroniles, he cannot answer some questions. For example:
Vasja is not so smart as Ares so he asks you to answer the questions mentioned. Write a program that answers them.
The first line of the input contains five integers N , M , F , L, Q - the number of cities, roads, regional enters; the length of King's route and the number of Vasja's questions (1 ≤ N ≤ 50, 1 ≤ M ≤ 100, 1 ≤ F ≤ N , 1 ≤ L ≤ 60, 1 ≤ Q ≤ 10000). The cities are enumerated with integers from 1 to N . The capital has number 1.
The following M lines describe the road system - three numbers in each line: Ai, Bi and Ci. Their meaning is that the i-th road is going from city number Ai to city number Bi, and its color is Ci (`0', if the road is red, `1', if it is blue).
The next line contains F different integers - the numbers of cities, that are regional enters.
The last Q lines contain one question each. The format of question description is the following:
The route is denoted by a sequence of L characters `0' and `1'.
It is guaranteed that all questions are correct and the answer always exists.
Output must contain T lines, one for each question. For question ! S it is required to output a single decimal integer. For all other questions the line must consist of L characters `0' and `1' - the record corresponding to the route.
1 2 1 3 2 1 1 0 1 1 1 1 ? 3 ! 111
2 3 2 5 4 1 1 0 1 2 1 2 1 0 2 1 ? 5 ! 00010 > 01010 < 01000
00101 3 10000 00101
4 6 1 6 5 1 2 0 2 3 0 3 4 0 4 3 1 3 2 1 2 1 1 1 ? 3 ? 4 > 000111 < 001101 ! 010101
001101 010011 001011 001011 5