#P1647. 锁

Description

Given NN and KK, you are to generate a sequence from 00 to 2N12^N-1. The first term of the sequence is 00, and the sequence must satisfy the following three conditions:

  1. The sequence has length 2N2^N, and every number from 00 to 2N12^N-1 is used exactly once.
  2. Any two adjacent numbers in the sequence are obtained by changing some bits of the previous number in its binary representation, where all the changed bits originally have the same value. That is, either change some 00s to 11s, or change some 11s to 00s, but not both at the same time.
  3. When multiple sequences satisfy the first two conditions, the sequence must be lexicographically smallest. In other words, when generating the next number from the previous one, always choose the smallest possible value (of course, still satisfying the first two conditions).

You are asked to find the maximum value among the first KK terms of this sequence. Output it in binary, with exactly NN bits, including leading zeros.

Input Format

A single line with two integers N,KN, K.

Output Format

A binary number representing the answer.

3 8
111

Hint

Sample Explanation

The generated sequence is [000,001,011,010,110,100,101,111][000,001,011,010,110,100,101,111]. The maximum among the first 88 terms is 111111.

Constraints

For all testdata, 1N50,1K2N1 \le N \le 50, 1 \le K \le 2^N.

Translated by ChatGPT 5