Demining#11335

Demining

1 second
128 megabytes
Medium

After the fighting, it became necessary to demine the area. The terrain is represented by a rectangular area of size n \times m, which may contain mines. The number of mines in sector is represented by an integer x_{ij}~(0 \le x_{ij} \le 10^9).

The military personnel use a quadcopter to take pictures of the area. Given rectangular pictures, help them determine the total number of mines captured in the pictures.

Input

The first line contains two positive integers and m~(1 \le n, m \le 1000) — the number of rows and columns, respectively.

The next lines contain integers x_{ij}~(0 \le x_{ij} \le 10^9) — the number of mines in the corresponding sector.

The next line contains an integer k~(1 \le k \le 1000) — the number of pictures taken by the quadcopter.

The next lines contain the coordinates of the rectangular pictures. Each line contains four integers: y_1, y_2, x_1, and x_2, where:

  • y_1 is the row number where the picture starts;

  • y_2 is the row number where the picture ends;

  • x_1 is the column number where the picture starts;

  • x_2 is the column number where the picture ends.

Output

Print one integer — the total number of mines captured in the pictures. Mines that are included in several pictures must be counted only once.

Examples

Example 1

Loading
Loading