#B3808. Quadrant Summation Transformation

    ID: 11465 Type: Default 1000ms 256MiB

Quadrant Summation Transformation

Quadrant Summation Transformation

You are given an integer N and an integer parameter k, and a sequence of length 2N: a1, a2, ..., a2N. The sequence is 1-indexed.

For the transformation, the following classification is applied:

  • An element ai is considered to be at an odd position if i mod 2 = 1, and at an even position if i mod 2 = 0.
  • An element ai is also classified into a quadrant based on its index: if i mod k = p, then it is called a quadrant p element.

The transformation rules are as follows:

  • If ai is at an even position, it remains unchanged.
  • If ai is at an odd position, let p = i mod k. Compute the sum of all the original elements that belong to quadrant p (i.e. for all indices j such that j mod k = p). Then, the new value of ai becomes: $$a_i = \Big(\sum_{\substack{j=1\\ (j\;mod\;k=p)}}^{2N} a_j\Big) \bmod i.$$ Note that the quadrant sum is computed from the original sequence and does not change during the transformation.

Your task is to output the transformed sequence in a single line, with the numbers separated by a single space.

inputFormat

The first line of the input contains two integers N and k.

The second line contains 2N space-separated integers representing the sequence: a1, a2, ..., a2N.

outputFormat

Output the transformed sequence in one line. The elements must be separated by a single space.

sample

2 3
1 2 3 4
0 2 0 4