
ZOJ Problem Set  2555
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 nonbit x to it, regard the new thingy as a cyclic string, and make this square matrix of bits
This matrix has the same number of rows as the length of the original bitstring. The mth row of the matrix has every mth bit of the original string starting with the mth 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.
InputEach line of input (except last) contains a prime number p ≤ 100000. The last line contains 0 and this line should not be processed.
OutputFor each prime number from the input produce one line of output containing the lexicographically smallest, nonconstant magic bitstring of length p1, if such a string exists, otherwise output Impossible.Sample Input5 3 17 47 2 79 0 Sample Output0110 01 0010111001110100 0000100001101010001101100100111010100111101111 Impossible 001001100001011010000001001111001110101010100011000011011111101001011110011011 Source: University of Waterloo Local Contest 2005.06.11 