Parity Sort

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You have a permutation PP of length nn. In this problem, elements of the permutation are integers from 00 to n1n - 1.

Your task is to perform the following operation up to 3030 times to sort PP in ascending order.

The operation is defined by two parameters: an integer tt denoting the mode of operation (0t10 \le t \le 1) and a string SS of length nn, consisting of 0s and 1s.

At the start of the process, we have two empty sequences, AA and BB.

Next, for each ii from 11 to nn, we repeat the following step:

  • If S_i=0S\_i = 0, do nothing.
  • If S_i=1S\_i = 1: if P_iP\_i is even, add P_iP\_i to the end of sequence AA, otherwise add P_iP\_i to the end of sequence BB.

If t=0t = 0, sequence CC is the concatenation of sequence AA and sequence BB in that order.

If t=1t = 1, sequence CC is the concatenation of sequence BB and sequence AA in that order.

Next, for each ii fron 11 to nn, we repeat the following step:

  • If S_i=0S\_i = 0, do nothing.
  • If S_i=1S\_i = 1, replace P_iP\_i with the first element of CC and erase the first element of CC.

For example, if n=7n = 7, P=0,4,2,3,6,5,1P = \\{0, 4, 2, 3, 6, 5, 1\\} and we choose t=1t = 1 and S=1101101S = `1101101`, the process is shown on the picture below.

입력

The first line of the input contains one integer nn (1n15,0001 \le n \le 15\\,000). The second line contains nn integers P_iP\_i (0P_in10 \le P\_i \le n - 1, P_iP_jP\_i \ne P\_j if iji \ne j).

출력

Print one of the possible sorting sequences in the following format:

On the first line, print one integer kk: the number of operations (0k300 \le k \le 30).

The ii-th of the following kk lines shall describe the ii-th operation and contain integer t_it\_i (0t_i10 \le t\_i \le 1) and binary string SS of length nn.

If there is more than one such sequence, choose any one of them. Note that you don't need to minimize kk.