Gray code is a binary numeral system where two successive values differ in only one bit. This property makes it useful in various applications, such as minimizing errors in digital communication and measurement systems. Gray code is also known for its reflective and cyclic characteristics, which help eliminate significant errors during random sampling. It was invented by Frank Gray in the 1940s and has various construction methods.
An $$$n$$$-bit Gray code $$$G_n=[G_{n,0},G_{n,1},\cdots,G_{n,2^n-1}]$$$ can be generated by the following algorithm:
For example, $$$G_2=[0,1,3,2]$$$, $$$G_3=[0,1,3,2,6,7,5,4]$$$.
Now there is an array $$$a_0,a_1,\cdots,a_{2^n-1}$$$ of length $$$2^n$$$. Initially, for all $$$i\in\{0,1,\cdots,2^n-1\}$$$, $$$a_i=i$$$. We will perform $$$q$$$ operations on this array, where each operation is one of the following two types:
Please output the results of each query in order.
The first line of input contains two integers, which are $$$n$$$ ($$$1\le n\le 10$$$) and $$$q$$$ ($$$1\le q\le 5000$$$).
The next $$$q$$$ lines describe the operations. Each of these lines starts with an integer $$$\text{op}$$$ ($$$\text{op}\in\{1,2\}$$$), indicating the type of operation.
It is guaranteed that the sum of $$$m$$$ over all type-1 operations does not exceed $$$5000$$$.
Output the binary forms of all the results of the type-2 operations without leading zeros, each on its own line.
3 42 01 4 1 2 3 22 1002 10
0 110 11
Initially, $$$[a_0,a_1,\cdots,a_{2^n-1}]=[0,1,2,3,4,5,6,7]$$$.
After the second operation, $$$[a_0,a_1,\cdots,a_{2^n-1}]=[0,1,3,2,6,7,5,4]$$$.