Under construction

Still being built. Things may change

Hongjun likes FFT

Time limit2sMemory limit512 MB

Summary
Generate permutations a and b with the given pseudocode, then compute c[i] = max over valid j of a[j]*b[i-j].
Level

Easy3 of 10

Topics
Array, Simulation, Implementation
Solved
No attempts yet

Problem

Hongjun likes the fast Fourier transform (FFT) and uses it often.

FFT is an algorithm for computing a convolution. Given sequences aa and bb of length nn, indexed from element 0 to element n−1n-1, FFT quickly produces the sequence cc defined below.

ci=∑j=0iajbi−jc_i = \sum_{j=0}^{i} a_j b_{i-j}

Hongjun replaced the sum in this formula with a maximum.

ci=max⁡0≤j≤iajbi−jc_i = \max_{0 \le j \le i} a_j b_{i-j}

To keep the computation easy, Hongjun only considers the case where aa holds each number from 11 to nn exactly once and every element of bb is 0 or 1. If every product is 0, then cic_i is 0. Write a program that computes the sequence cc once aa and bb are fixed.

Hongjun is lazy, so he does not want to list the elements of aa and bb one by one. He gives only three integers nn, dd, xx and wants you to build both sequences yourself with the pseudocode below. % is the remainder operator and swap() exchanges two values. Following the pseudocode, bb contains exactly dd ones.

//x is 64-bit variable;
function getNextX() {
    x = (x * 37 + 10007) % 1000000007;
    return x;
}
function initAB() {
    for(i = 0; i < n; i = i + 1){
        a[i] = i + 1;
    }
    for(i = 0; i < n; i = i + 1){
        swap(a[i], a[getNextX() % (i + 1)]);
    }
    for(i = 0; i < n; i = i + 1){
        if (i < d)
            b[i] = 1;
        else
            b[i] = 0;
    }
    for(i = 0; i < n; i = i + 1){
        swap(b[i], b[getNextX() % (i + 1)]);
    }
}

Input

The first line contains three integers nn, dd, xx separated by spaces. (1≤d≤n≤100,0001 \le d \le n \le 100{,}000, 0≤x≤1,000,000,0060 \le x \le 1{,}000{,}000{,}006)

Output

Print the elements of the sequence cc, from element 0 to element n−1n-1, on one line separated by spaces.

Examples3

  1. Example 1

    Input
    3 1 1
    
    Expected output
    1 3 2
    
  2. Example 2

    Input
    1 1 0
    
    Expected output
    1
    
  3. Example 3

    Input
    5 2 100
    
    Expected output
    0 0 0 5 5