#c22704. 二维差分

二维差分

2D Difference Array

Problem Description

You are given an n×mn \times m matrix a1,1,a1,2,…,a1,m,…,an,ma_{1,1}, a_{1,2}, \dots, a_{1,m}, \dots, a_{n,m} and qq update operations.

Initially all positions are 00. Each update gives five numbers x1,y1,x2,y2,dx_1, y_1, x_2, y_2, d and adds dd to every ai,ja_{i,j} with x1≤i≤x2x_1 \leq i \leq x_2 and y1≤j≤y2y_1 \leq j \leq y_2.

Compute the value of the whole matrix after all operations.

Input Format

The first line contains six integers n,m,q,A,B,Cn, m, q, A, B, C (1≤n,m≤2×1031 \leq n, m \leq 2\times 10^3, 1≤q≤1061 \le q \leq 10^6, 0≤A,B,C<2320 \leq A, B, C < 2^{32}).

To avoid overly large input, the queries are generated by the following code.

int n, m, q;
unsigned int A, B, C;
unsigned int a[N][N];
inline unsigned int rng61() {
    A ^= A << 16;
    A ^= A >> 5;
    A ^= A << 1;
    unsigned int t = A;
    A = B;
    B = C;
    C ^= t ^ A;
    return C;
}
int main(){
    scanf("%d%d%d%u%u%u", &n, &m, &q, &A, &B, &C);
    for (int i = 1; i <= q; i++) {
        int x1 = rng61() % n + 1, x2 = rng61() % n + 1;
        int y1 = rng61() % m + 1, y2 = rng61() % m + 1;
        unsigned int d = rng61();
        if (x1 > x2) swap(x1, x2);
        if (y1 > y2) swap(y1, y2);
        // perform the update operation
    }
}

Output Format

To avoid overly large output, output the XOR sum of all numbers in the matrix after all operations.

Sample Input

5 5 10 1 2 3

Sample Output

3809069637