GrayInc#786

GrayInc

1 second
64 megabytes
Hard

Gray Inc. is a software manufacturer specialized in the management of Gray codes. An -binary code, for n \geq 1, is a sequence of words w_0, w_1, \ldots that includes every possible binary word of bits. An -Gray code is an -binary code such that between any two consecutive words there is only one bit that changes, i.e., they differ at exactly one position. As you might be aware, there are many -Gray codes.

Gray Inc. produces its own particular kind of Gray code in the following way (name G_n the produced -Gray code, n \geq 1):

The notation defining G_n should be understood as follows:

For instance,

and

Observe that not only G_n is an -Gray code, but also a circular Gray code, as the first word in the sequence may be regarded as the successor of the last one in the sequence.

Gray Inc. wants your help to solve the following problem: given a binary word in G_n and a natural number , they want to produce the binary word in the sequence G_n that is words after in the listing (of course, considering the circular ordering described above). Can you help them?

Input

The problem input consists of several cases, each one defined by a line with an integer (0 < m \leq 1000), and a binary -word (1 \leq n \leq 100), separated by one blank.

The end of the input is given by a line with m = 0 and w = 0.

Output

For each input case, your solution should output the -binary word that is words after in the listing of G_n.

Examples

Example 1

Loading
Loading