Magic Bitstrings
ID: 1141
Description
A bitstring, whose length is one less than a prime, might be magic. 1001 is one such string. In order to see the magic in the string let us append a non-bit x to it, regard the new thingy as a cyclic string, and make this square matrix of bits

each bit   1001  
every 2nd bit   0110  
every 3rd bit   0110  
every 4th bit   1001  


This matrix has the same number of rows as the length of the original bitstring. The m-th row of the matrix has every m-th bit of the original string starting with the m-th bit. Because the enlarged thingy has prime length, the appended x never gets used.

If each row of the matrix is either the original bitstring or its complement, the original bitstring is magic.
Input
Each testcase contains a prime number p ≤ 100000.
Output
For each prime number from the input produce one line of output containing the lexicographically smallest, non-constant magic bitstring of length p-1, if such a string exists, otherwise output Impossible.
Sample Test Cases
InputExpected Output
5
0110
3
01
17
0010111001110100
Tags
Statistics
The Tops
Shortest Submission ardian kristanto-p (ntu) 0.33 kB GNU C++ view
Most Popular Submission duc-n (nus) 1.00 C# 3.0 view