Binary Neural Network

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

문제

An artificial neural network, often called just a neural network, is a mathematical model inspired by biological neural networks. A neural network consists of an interconnected group of artificial neurons, and it processes information using a connectionist approach to computation.

The neural network is called layered if its neurons are organized into groups called layers. There is no connection between two neurons belonging to the same layer.

Let us number the neurons with sequential positive integers from 11 to qq, where qq is the number of neurons in the network. The connection between neuron ii and neuron jj can be described with the connection weight w_i,jw\_{i, j}.

A neural network can be represented as a directed acyclic graph: neurons can be represented by the vertices, and connections between neurons --- by the edges. The connection weight for each connection can be represented as the weight of the corresponding edge.

In the image above there is a neural network consisting of four layers. The first layer contains neurons 11, 22 and 33, the second layer contains neurons 44 and 55, the third layer consists of neurons 66, 77 and 88, and the fourth one contains the only neuron 99.

Each neuron ii has its value v_iv\_{i}, which is calculated by the following formula:

v_i=11+e_jv_jw_j,iv\_{i} = \frac{1}{1 + e^{- \sum\_{j}^{ } v\_{j} \cdot w\_{j, i}}}

The layered neural network is called binary neural network if it has the following properties:

  • For each neuron ii of the first layer the value v_iv\_{i} is either 00 or 11;
  • If neuron aa belongs to the layer ii, neuron bb belongs to the layer jj and i>ji > j, then there is no connection from neuron aa to neuron bb. Note that the connection from neuron bb to neuron aa is still possible;
  • The last layer has the only neuron and its value is either 00 or 11;
  • Each layer contains at least one neuron.

In this problem you are to create a binary neural network that implements the binary function f(x_1f(x\_{1}, x_2x\_{2}, \ldots x_n)x\_{n}) with nn arguments.

The first layer of this binary neural network should contain exactly nn neurons numbered with sequential positive integers from 11 to nn. The value of neuron ii will be automatically set to x_ix\_{i}. All the other neurons should be numbered with sequential positive integers from n+1n + 1 to qq, where qq is the number of neurons in the network. All the values v_iv\_{i} (n+1iqn + 1 \leq i \leq q) will be calculated by the formula that is given above.

The last layer of this binary neural network should contain the only neuron. The value of this neuron should differ from the value f(x_1f(x\_{1}, x_2x\_{2}, \ldots x_n)x\_{n}) by no more than 10710^{-7}.

The binary network should not contain more than 2525 layers. The number qq of neurons should not be greater than 10410^{4}. The total number ee of connections should not be greater than 31043 \cdot 10^{4}.

입력

The first line of input contains the only integer nn (2n102 \leq n \leq 10). The second line of input contains 2n2^{n} characters. Each of these characters is either '0' or '1'. The first character describes the value of f(0,,0,0)f(0, \ldots, 0, 0), the second one describes the value of f(0,,0,1)f(0, \ldots, 0, 1) and so on, the last one describes the value of f(1,,1,1)f(1, \ldots, 1, 1).

출력

On the first line output two integers ll and qq --- the number of layers and the number of neurons in the binary neural network respectively (2l252 \leq l \leq 25, 1q1041 \leq q \leq 10^{4}).

On the second line output qq integers p_ip\_{i}. Here p_ip\_{i} is the number of layer that the neuron ii belongs to (1p_il1 \leq p\_{i} \leq l).

On the third line output the only integer ee --- the number of connections in the binary neural network (ne3104n \leq e \leq 3 \cdot 10^{4}).

Each of the following ee lines should contain two integers a_ia\_{i}, b_ib\_{i} and one real number w_a,bw\_{a, b} --- description of the connection from a_ia\_{i} to b_ib\_{i} with the weight w_a,bw\_{a, b} (w_a,b1000|w\_{a,b}| \le 1000).