cho.sh
Notes
Loading...

Chain Store Location

Time limit

1s

Memory limit

256 MB

Problem

Hong Gil-dong is choosing a site for a chicken chain store. The road map of the area is shown below. Circles are candidate store sites, lines are roads, and the number beside each line is the road length. There are three large apartment complexes, marked A, B, and C. Every intersection is incident to at most five roads, and every site is reachable from every other site by roads.

Suppose a store is opened at candidate site 1 in the picture. The shortest-path distances from site 1 to apartment complexes A, B, and C are 8, 16, and 9. These are all larger than the corresponding distances from candidate site 4, which are 6, 7, and 3. Since customers tend to use a closer store, site 1 is worse than site 4 in every distance comparison. Candidate site 6 has distances 5, 3, and 5, so it is better than site 1 in every comparison, but compared with site 4 it is better for A and B and worse for C.

Hong Gil-dong therefore uses the following rule.

Let the shortest-path distances from candidate site p to apartment complexes A, B, and C be a, b, and c. If there exists another candidate site q whose shortest-path distances to A, B, and C are x, y, and z, and a > x, b > y, and c > z, then a store will not be opened at p.

For each queried candidate site, determine whether a store can be opened there. A store may also be opened at a site where an apartment complex is located.

Input

The first line contains an integer N, the number of candidate store sites (1 <= N <= 100000). The sites are numbered from 1 to N.

The second line contains three distinct integers A, B, and C, the locations of the apartment complexes. Each is one of the candidate sites.

The third line contains an integer M, the number of roads. Each of the next M lines contains three integers X, Y, and Z, meaning that there is a road of length Z between candidate sites X and Y (1 <= Z <= 10000). No road appears more than once. The whole road graph is connected, and each site is incident to at most five roads.

The next line contains an integer T, the number of queries (1 <= T <= 10000). Each of the next T lines contains one integer Q (1 <= Q <= N), the queried candidate site.

Output

For each query Q, print YES in uppercase if a store can be opened at candidate site Q; otherwise print NO.