Rectangles

Time limit: 0.25s Memory limit: 256MB Input: Output:

You are given a matrix with nn rows and mm columns. Its entries are consecutive starting from 00 left to right, top to bottom like below:

0 0\ 1 1\ 2 2\ 3 3\ 4 4\
5 5\ 6 6\ 7 7\ 8 8\ 9 9\
10 10\ 11 11\ 12 12\ 13 13\ 14 14\
15 15\ 16 16\ 17 17\ 18 18\ 19 19\

There are qq operations which modify the matrix in the following way: a submatrix is chosen inside the matrix and it will be inverted horizontally and vertically. For example if the submatrix with the top-left coordinate (1,3)(1, 3) and bottom-right coordinate (3,5)(3, 5) is inverted on the one above it will look like this:

0 0\ 1 1\ 14 14\ 13 13\ 12 12\
5 5\ 6 6\ 9 9\ 8 8\ 7 7\
10 10\ 11 11\ 4 4\ 3 3\ 2 2\
15 15\ 16 16\ 17 17\ 18 18\ 19 19\

You are also given the coordinates (x,y)(x, y) of a cell, type the value of that cell after all qq operations.

Input

The first line will contain 55 integers, n,m,q,xn, m, q, x and y(1n,m109),(1q3105),(1x,yn)y (1 ≤ n, m ≤ 10^9), (1 ≤ q ≤ 3 \cdot 10^5), (1 ≤ x, y ≤ n).

The following qq lines will contain x1,y1,x2x_1, y_1, x_2 and y2y_2 which describe the top-left, bottom-right coordinates of the submatrix (1x1x2n),(1y1y2n)(1 ≤ x_1 ≤ x_2 ≤ n), (1 ≤ y_1 ≤ y_2 ≤ n).

For tests worth 2020 points it is guaranteed that (1n,m100),(1q100)(1 ≤ n, m ≤ 100), (1 ≤ q ≤ 100)

Example

stdin

4 5 1 1 3
1 3 3 5

stdout

14

Log in or sign up to be able to send submissions!