The Hilbert curve, invented by the German mathematician David Hilbert, is one of the most famous fractal curves. The i-th Hilbert curve gives a sequential ordering of the cells in a

grid.
The formal definition of Hilbert curves is recursive. The i-th Hilbert curve can be formed by connecting four (i-1)-th Hilbert curves, in the following way:
1. partition the

grid into four

quadrants;
2. reflect an (i-1)-th Hilbert curve across the main diagonal (from top left to bottom right), and place it in the upper left quadrant;
3. place two copies of the (i-1)-th Hilbert curve in the lower left and lower right quadrants, respectively;
4. reflect an (i-1)-th Hilbert curve across the secondary diagonal (from top right to bottom left), and place it in the upper right quadrant.
The first three Hilbert curves are shown below.
The Hilbert sort, just as the name implies, is to sort a set of the cells according to the Hilbert curve. A cell is ranked before another if it is encountered earlier when walking along the Hilbert curve. The Hilbert sort is widely used in many areas, because such sort maps a set of 2-dimensional data points into 1-dimensional space, with spatial locality preserved fairly well.
Give you an integer k and a set of cells in the

grid, please sort them in the order induced from the k-th Hilbert curve.