Day off
Heinz Fufelschmertz has a day off today. He decided not to invent any "inator", but simply lie on the beach and drink cocktails. As a result, he dozed off in the sun and had a rather strange dream.
In the dream, there was an endless checkered field, which Heinz looked down on. There was a dice on this field. Moreover, the lower side of the cube ideally coincided with the cell of the field. If you look at the cube from above, then initially the number x[1]
was written on the bottom face, the number x[6]
on the top face, on the face looking north x[2]
, to the south x[5]
, west x[3]
, east x[4]
.
Heinz supported two values: the number s, initially equal to 0, and the direction d, initially pointing north. Then, he performed the following action several times:
Now let the number x be written on the top face of the cube. Heinz adds x to s. Also, x times rotates d clockwise by 90 degrees.
It rolls the die over the bottom edge in the direction d. Thus, the side face, which previously looked in the direction d, became the new bottom face.
When Doofenshmirtz woke up, he wondered what s could be after a few steps. Help him.
Input
The first line contains six integers x[1]
, x[2]
, x[3]
, x[4]
, x[5]
and x[6]
(* 1* ≤ x[i]
≤ 100) - numbers written on the sides of the cube.
The second line contains an integer t (1 ≤ t ≤ 10^5
) - the number of s values that Fufelschmertz is interested in.
The next t lines contain one integer q[i]
each (1 ≤ q[i]
≤ 10^18
).
Output
For each number q[i]
print "Yes" if the number s could be equal to q[i]
as a result of several operations and "No" otherwise.