Medium Hadron Collider

N-1번의 일관된 게이트 작동 뒤 1번부터 128번 구간의 빔 전하를 알아내야 한다. 129번부터 512번 구간에서 최대 10번 측정할 수 있고, 검출기는 7자리를 넘으면 값을 감싼다.

어려움9수학정수론조합론구현아직 제출이 없습니다시간 제한4초메모리 제한512 MB

문제

Okarin Kyouma is a brilliant scientist working on Medium Hadron Collider (MHC) in Société Européenne de Recherche Nucléaire (SERN). His current experiments aim to unravel the mysterious Stein's gate effect.

MHC consists of a sufficiently large amount of sections arranged on a line and numbered 1,2,3,1, 2, 3, \dots along the line. Particle beams traverse through sections in ascending order of section numbers, it takes one second for a beam to pass any section. There are two types of beams which may be present in MHC: electronic beams ee^{-} and positronic beams e+e^{+}.

Initially, there is a single electronic beam in the beginning of the first section of MHC. Each section is affected by the Stein's gate effect. When a particle beam goes through the center of section i>1i>1, the gate is triggered and creates another beam in the center of section i1i-1. This new beam is either the same or inverted (that is, e+e^{+} instead of ee^{-}, and vice versa). The new beam moves in the same direction and with the same speed as the initial beam. Beam recreation is coherent: at each step, either all sections produce the same beams or all sections produce inverted beams. 

Then created beam interferes with the one already present in the section, if any. Beams of the same type merge, while beams of opposite types annihilate. Formally, we may say that a single electronic beam has charge 1-1, single positronic beam has charge +1+1, and an "empty" beam has charge 00. The result of collision of beams with charges α\alpha and β\beta will be a beam with charge γ=α+β\gamma = \alpha + \beta. Here are a few examples:

  • A single electronic beam colliding with a single positronic beam leave an "empty" beam.
  • Two single positronic beams become a "double" positronic beam with total charge +2+2.
  • A positronic beam with total charge +5+5 colliding with an electronic beam with total charge 8-8 become an electronic beam with total charge 3-3.

The end of the NN-th second of experiment approaches. So, the Stein's gate effect was activated exactly N1N-1 times, but the initial electronic beam is yet in the section numbered NN. Okarin wants to measure the total charge of beams traversing through some sections but, unfortunately, measurement tools for sections 11 through 128128 are out of reach. Okarin needs these values urgently, but he only has time to check the measurements in at most 1010 sections. Moreover, he does not have proper permission to get measurements in sections beyond number 512512, thus he may only ask about sections from 129129 to 512512 inclusively.

You need to help Okarin recover measures in sections from 11 to 128128. Note that detectors in sections are not perfect, and can only show 77 digits and the sign. Thus, for example, if a detector approaches +10,000,000+10\\,000\\,000, it will show 9,999,999-9\\,999\\,999 instead. After that, +10,000,001+10\\,000\\,001 will be shown as 9,999,998-9\\,999\\,998, and so on.

힌트

The example for this problem has N=4N=4 and does not coincide with the actual first test case. In the example, the Stein's gate effect was activated three times. Let us assume that its first and second activations produced the same beams, and the third activation produced inverted beams. Then:

  1. Initially, there is a single beam with charge 1-1 in the first section.
  2. After 1.51.5 seconds, the initial beam goes through the center of the second section and is recreated in the center of the first section. At this moment, we have beams with charges 1-1 in the centers of first and second sections.
  3. After 2.52.5 seconds, the initial beam goes through the center of the third section, while its copy goes through the center of the second section. Both beams are recreated the same in preceding sections. Then the first copy of the initial beam in the second section interferes with the new copy. After that, we have beams with total charges 1-1, 2-2 and 1-1 in the centers of first, second, and third sections correspondingly.
  4. After 3.53.5 seconds, beams once again pass centers of sections. But this time, they are recreated with inverted signs. After all collisions, we will have a beam with charge +1+1 in the first section, a beam with charge +1+1 in the second section, a beam with charge 1-1 in the third section, and a beam with charge 1-1 in the fourth section.

In the example, the solution asks what are the charges in sections from 11 to 55, and then outputs the charges in sections from 11 to 44.
Recall that, in the actual test cases, the solution can ask only about sections 129129 to 512512, and must then output the measurements in sections 11 to 128128.