Raul and Deniz are playing True or False. Being computer scientists, they changed the game's settings, and now the questions are different. The game now proceeds as follows:
- Raul and Deniz receive the numbers , , and a sequence of natural numbers.
- There are questions of the form: "Given the numbers , , and (). Tell if is equal to ". Raul and Deniz need to quickly determine if they should say True or False.
Task
To answer these questions very quickly, they asked you to help write a program that responds as quickly as possible to these queries.
Input data
The first line contains two natural numbers, and .
The second line contains natural numbers, representing the sequence .
The next lines each contain a triplet of numbers, representing , , and in this order.
Output data
Print a sequence of characters, with the -th character being if the answer to the -th query is true, and otherwise.
Constraints and clarifications
- It is recommended to print the entire sequence of characters ( or ) once, at the end of the queries
# | Points | Constraints |
---|---|---|
1 | 12 | |
2 | 15 | |
3 | 11 | |
4 | 62 | No other constraints |
Example 1
stdin
8 12
1 5 5 2 4 9 3 2
1 2 2
1 2 1
2 3 2
2 3 2
2 4 3
2 4 4
2 4 2
1 6 6
7 8 8
4 5 4
3 6 3
3 6 6
stdout
101110110001
Explanation
,
The answer to the first query is true because , , , , and . So, . Therefore, the character to be printed is .
The answer to the second query is false because , , , , but . Therefore, the character to be printed is .
The answer to the fifth query is true because , , , and . Therefore, the character to be printed at the fifth position is .