• # For Solution

As mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from 00 to 2n12n−1. On each planet, there are gates that allow the player to move from planet ii to planet jj if the binary representations of ii and jj differ in exactly one bit.

William wants to test you and see how you can handle processing the following queries in this game universe:

• Destroy planets with numbers from ll to rr inclusively. These planets cannot be moved to anymore.
• Figure out if it is possible to reach planet bb from planet aa using some number of planetary gates. It is guaranteed that the planets aa and bb are not destroyed.
Input Gates to Another World solution codeforces

The first line contains two integers nnmm (1n501≤n≤501m51041≤m≤5⋅104), which are the number of bits in binary representation of each planets’ designation and the number of queries, respectively.

Each of the next mm lines contains a query of two types:

block l r — query for destruction of planets with numbers from ll to rr inclusively (0lr<2n0≤l≤r<2n). It’s guaranteed that no planet will be destroyed twice.

ask a b — query for reachability between planets aa and bb (0a,b<2n0≤a,b<2n). It’s guaranteed that planets aa and bb hasn’t been destroyed yet.

Output Gates to Another World solution codeforces

For each query of type ask you must output “1” in a new line, if it is possible to reach planet bb from planet aa and “0” otherwise (without quotation marks).

Examples
input

Copy
3 3
block 3 6

output

Copy
1
0

input

Copy Gates to Another World solution codeforces
6 10
block 12 26
block 32 46
block 27 30
block 31 31

output Gates to Another World solution codeforces

Copy
1
1
0
0
1
0

Note

The first example test can be visualized in the following way:

Response to a query ask 0 7 is positive.

Next after query block 3 6 the graph will look the following way (destroyed vertices are highlighted):

Response to a query ask 0 7 is negative, since any path from vertex 00 to vertex 77 must go through one of the destroyed vertices.