Yandex.Algorithm 2011: Round 2
E
Long sequence
Codeforces
2700
原题
← D→
翻译中…

A sequence $*a*_{0}, *a*_{1}, ...$ is called a recurrent binary sequence, if each term $*a*_{*i*}$ $(*i* = 0, 1, ...)$ is equal to 0 or 1 and there exist coefficients image such that

翻译中…

$*a*_{*n*} = *c*_{1}·*a*_{*n* - 1} + *c*_{2}·*a*_{*n* - 2} + ... + *c*_{*k*}·*a*_{*n* - *k*} (*mod* 2),$

翻译中…

for all

翻译中…

n ≥ k

翻译中…

. Assume that not all of

翻译中…

ci

翻译中…

are zeros.

翻译中…

Note that such a sequence can be uniquely recovered from any $*k*$-tuple ${*a*_{*s*}, *a*_{*s* + 1}, ..., *a*_{*s* + *k* - 1}}$ and so it is periodic. Moreover, if a $*k*$-tuple contains only zeros, then the sequence contains only zeros, so this case is not very interesting. Otherwise the minimal period of the sequence is not greater than $2^{*k*} - 1$, as $*k*$-tuple determines next element, and there are $2^{*k*} - 1$ non-zero $*k*$-tuples. Let us call a sequence long if its minimal period is exactly $2^{*k*} - 1$. Your task is to find a long sequence for a given $*k*$, if there is any.

翻译中…

Input

翻译中…

Input contains a single integer $*k*$ ($2 ≤ *k* ≤ 50$).

翻译中…

Output

翻译中…

If there is no long sequence for a given $*k*$, output "-1" (without quotes). Otherwise the first line of the output should contain $*k*$ integer numbers: $*c*_{1}, *c*_{2}, ..., *c*_{*k*}$ (coefficients). The second line should contain first $*k*$ elements of the sequence: $*a*_{0}, *a*_{1}, ..., *a*_{*k* - 1}$. All of them (elements and coefficients) should be equal to 0 or 1, and at least one $*c*_{*i*}$ has to be equal to 1.

翻译中…

If there are several solutions, output any.

翻译中…

Note

翻译中…
  1. In the first sample: $*c*_{1} = 1$, $*c*_{2} = 1$, so $*a*_{*n*} = *a*_{*n* - 1} + *a*_{*n* - 2} (*mod* 2)$. Thus the sequence will be:
翻译中…

image

翻译中…

so its period equals $3 = 2^{2} - 1$.

翻译中…
  1. In the second sample: $*c*_{1} = 0$, $*c*_{2} = 1$, $*c*_{3} = 1$, so $*a*_{*n*} = *a*_{*n* - 2} + *a*_{*n* - 3} (*mod* 2)$. Thus our sequence is:
翻译中…

image

翻译中…

and its period equals $7 = 2^{3} - 1$.

翻译中…

Periods are colored.

翻译中…

样例

Input #1
2
Output #1
1 1
1 0
InputCopy OutputCopy
Input #2
3
Output #2
0 1 1
1 1 1
InputCopy OutputCopy
题目信息
题号
86E
时间限制
2 s
内存限制
256 MB
标签
暴力
数学
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。