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:

00 11 22 33 44
55 66 77 88 99
1010 1111 1212 1313 1414
1515 1616 1717 1818 1919

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:

00 11 1414 1313 1212
55 66 99 88 77
1010 1111 44 33 22
1515 1616 1717 1818 1919

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!