#P10950. De Bruijn Drum Sensor Configuration

    ID: 12999 Type: Default 1000ms 256MiB

De Bruijn Drum Sensor Configuration

De Bruijn Drum Sensor Configuration

Vani is repairing a damaged drum in which the key component is a set of MM sensors arranged in a circle. Each sensor has two states: on (1) and off (0). If you start from every sensor and read KK consecutive sensors in the clockwise direction (wrapping around the circle), you obtain MM binary strings of length KK. Vani knows that these MM strings must all be distinct, and furthermore the drum design is so precise that MM takes on the maximum possible value. Given KK, your task is to compute MM and output the lexicographically smallest sensor configuration that satisfies these properties.

Note: A valid configuration is a circular binary sequence such that every possible binary string of length KK (there are 2K2^K of them) appears exactly once as a contiguous subsequence. This sequence is known as a de Bruijn sequence for KK-tuples over the alphabet {0, 1}.

inputFormat

The input consists of a single integer KK (1K201 \le K \le 20) representing the length of the binary strings.

outputFormat

Output two lines. The first line contains the integer MM, which is 2K2^K. The second line contains the lexicographically smallest de Bruijn sequence (a binary string of length MM) representing the sensor configuration.

sample

1
2

01

</p>