Day off#11097

Day off

1 second
128 megabytes
Hard

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 , initially equal to , and the direction , initially pointing north. Then, he performed the following action several times:

When Heinz woke up, he wondered what 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 \leq x_i \leq 100) - numbers written on the sides of the cube.

The second line contains an integer (1 \leq t \leq 10^5) - the number of values that Fufelschmertz is interested in.

The next lines contain one integer q_i each (1 \leq q_i \leq 10^{18}).

Output

For each number q_i print "Yes" if the number could be equal to q_i as a result of several operations and "No" otherwise.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading