By Guilherme Londe, PUC Goiás Brazil
A meticulous farmer decided to distribute pequis (pequi is a fruit native from brazilian cerrado) to his workers. He has N workers and a list S with N integer values. He wants to distribute the pequis in steps.
Initially no worker have pequis. On the first step the farmer gives S1 pequis to the first worker, S2 to the second and so on until he gives SN to the N-th worker. In each of the next steps the farmer removes the value at the end of S, pushes that on the beginning of S and give the pequis again as was done in the first step. The example below shows a distribution of pequis in three steps, for N = 4 and S = {3, 0, 1, 0}, in which the column Workers contains the amount of pequis each worker will have after the execution of each step.
As the number of workers and steps is too big, the farmer asked you to help writing a program that shows the final amount of pequis each worker will have after the execution of the last step.
The first line of the input contains an integer N (1 ≤ N ≤ 103) followed by an integer K (1 ≤ K ≤ 106), that are the number of workers and the number of steps, respectively. The next line contains the values S1, S2, … , SN, where 0 ≤ Si ≤ 103 for all 1 ≤ i ≤ N.
The output consists of just one line containing the amount of pequis each of the N workers will have after the end of the K-th step, both separated by whitespaces.
Input Samples | Output Samples |
4 3 |
4 3 4 1 |
3 8 |
45 41 42 |