Under construction

Still being built. Things may change

Coffee Milk

Time limit3sMemory limit1024 MB

Summary
Given a tetrahedron with integer vertices and N scale factors K, count the lattice points on its surface and inside it for each K, modulo 1003003001.
Level

Hard8 of 10

Topics
Math, Geometry, Number theory
Solved
No attempts yet

Problem

W Dairy sells a coffee milk in the shape of a triangular pyramid. The capacity of the coffee milk is the number of lattice points on the boundary of the space it occupies and inside that space.

To mark the 10th anniversary of the coffee milk, W Dairy plans to release a new product that is the original scaled by KK. The original is a triangular pyramid with vertices PP, QQ, RR, and SS in three-dimensional space. The new product is a triangular pyramid whose vertices are (Kx,Ky,Kz)(Kx, Ky, Kz), where (x,y,z)(x, y, z) is each vertex of the original multiplied by KK.

Given NN candidate values of KK, find the capacity of the new product for each candidate.

The answer can be very large, so print the capacity modulo 1 003 003 0011\,003\,003\,001.

Input

The first line contains the number of candidates NN for KK (1≤N≤200 0001 \le N \le 200\,000).

The second line contains the integers xPx_P, yPy_P, and zPz_P, the x, y, and z coordinates of PP, separated by spaces (−100≤xP,yP,zP≤100-100 \le x_P, y_P, z_P \le 100).

The third line contains the integers xQx_Q, yQy_Q, and zQz_Q, the coordinates of QQ, separated by spaces (−100≤xQ,yQ,zQ≤100-100 \le x_Q, y_Q, z_Q \le 100).

The fourth line contains the integers xRx_R, yRy_R, and zRz_R, the coordinates of RR, separated by spaces (−100≤xR,yR,zR≤100-100 \le x_R, y_R, z_R \le 100).

The fifth line contains the integers xSx_S, ySy_S, and zSz_S, the coordinates of SS, separated by spaces (−100≤xS,yS,zS≤100-100 \le x_S, y_S, z_S \le 100).

The sixth line contains the NN candidate values C1C_1, C2C_2, ⋯\cdots, CNC_N for KK, separated by spaces (1≤Ci≤1091 \le C_i \le 10^9).

The volume of the triangular pyramid PQRSPQRS is greater than 00.

Output

For each candidate KK, print the capacity of the new product modulo 1 003 003 0011\,003\,003\,001. Separate the answers with spaces.

Examples3

  1. Example 1

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

    Input
    1
    -3 1 7
    -8 -1 0
    -5 0 0
    0 2 0
    9
    
    Expected output
    940
    
  3. Example 3

    Input
    1
    -100 -100 -100
    -100 100 100
    100 -100 100
    100 100 -100
    1000000000
    
    Expected output
    16674283