This page is still under construction.

Parts of this page are still being built. What you see may change.

Cube Coloring

Time limit2sMemory limit128 MB

Summary
Count the cubes in an X by Y by Z box by Manhattan distance from a given cube modulo N.
Level

Medium7 of 10

Topics
Combinatorics, Prefix sum, Math
Solved
No attempts yet

Problem

The painter Cubic makes his works out of cubes. For the current piece he stacks 1×1×11 \times 1 \times 1 cubes into an X×Y×ZX \times Y \times Z rectangular box, and every pair of touching cubes shares a full face.

Stacking alone does not finish the piece. Cubic labels the position of each cube from (0,0,0)(0,0,0) to (X−1,Y−1,Z−1)(X-1,Y-1,Z-1) in the usual coordinate system and calls the cube at (A,B,C)(A,B,C) the origin cube. He then picks a color for every cube from its distance to the origin cube and paints it. He paints the cubes buried inside the box too, even though nobody will see them. That is his rule.

Distance here means Manhattan distance. The Manhattan distance between the cubes (x1,y1,z1)(x_1,y_1,z_1) and (x2,y2,z2)(x_2,y_2,z_2) is ∣x1−x2∣+∣y1−y2∣+∣z1−z2∣|x_1-x_2| + |y_1-y_2| + |z_1-z_2|.

Cubic uses NN colors numbered 11 to NN. A cube whose distance DD to the origin cube satisfies D≡i(modN)D \equiv i \pmod{N} gets color i+1i+1.

Cubic wants to know in advance how much of each color he needs. Write a program that computes, for every color, the number of cubes painted with it.

Input

One line holds seven integers XX, YY, ZZ, AA, BB, CC, NN, separated by single spaces. XX, YY, ZZ (1≤X,Y,Z≤1061 \le X, Y, Z \le 10^6) are the side lengths of the box. AA, BB, CC (0≤A<X0 \le A < X, 0≤B<Y0 \le B < Y, 0≤C<Z0 \le C < Z) are the coordinates of the origin cube. NN (1≤N≤10001 \le N \le 1000) is the number of colors.

Output

Print NN integers on one line, separated by single spaces. The ii-th integer (1≤i≤N1 \le i \le N) is the number of cubes painted with color ii.

Examples3

  1. Example 1

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

    Input
    4 3 3 1 1 1 3
    
    Expected output
    13 10 13
    
  3. Example 3

    Input
    2000 2000 2000 1000 1000 1000 1
    
    Expected output
    8000000000