G. Armando and the Mines
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Armando had been through a lot. He had known defeat, survived questionable decisions and learned, almost always the hard way, that not all roads lead to happiness.

After so many experiences, he decided to leave chaos behind. He meditated, found inner peace and reached a deep state of zen. Then, with the serenity of someone who finally understands the universe, he thought: "A true man cannot step on any mine."

But fate still had one last test for him: crossing the dreaded battlefield known as Parque Lincoln. Reaching enlightenment does not include knowing the exact location of the explosives: all Armando has is a map with the regions where they might be. And, true to his new philosophy, Armando never steps back: he only moves right or up.

Fictional illustration; it does not depict a real situation in the park.

Parque Lincoln is a grid of $$$H$$$ rows and $$$W$$$ columns. Cell $$$(x, y)$$$ is in column $$$x$$$, counted from left to right, and in row $$$y$$$, counted from bottom to top. The bottom-left corner is $$$(1, 1)$$$.

The map marks $$$K$$$ rectangles that do not share cells. Each rectangle has exactly one mine, in one of its $$$S$$$ cells, chosen at random: each cell has probability $$$1/S$$$, independently of the other rectangles. Outside the rectangles there are no mines.

Armando goes from $$$A = (x_A, y_A)$$$ to $$$B = (x_B, y_B)$$$, and in each step he moves from $$$(x, y)$$$ to $$$(x + 1, y)$$$ or to $$$(x, y + 1)$$$. Before leaving, without knowing where the mines are, he chooses his whole path. The number of mines of a path is the number of mines in its cells, counting $$$A$$$ and $$$B$$$.

Help Armando: what is the minimum expected value of the number of mines on his path?

Input

The first line contains three integers $$$H$$$, $$$W$$$ and $$$K$$$.

The second line contains four integers $$$x_A$$$, $$$y_A$$$, $$$x_B$$$ and $$$y_B$$$.

Each of the following $$$K$$$ lines contains four integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$ and $$$y_2$$$: the rectangle formed by the cells $$$(x, y)$$$ with $$$x_1 \le x \le x_2$$$ and $$$y_1 \le y \le y_2$$$. Its number of cells is $$$S = (x_2 - x_1 + 1)(y_2 - y_1 + 1)$$$.

Constraints

  • $$$1 \le H, W \le 1000$$$
  • $$$0 \le K \le \min(10^5, H \cdot W)$$$
  • $$$1 \le x_A \le x_B \le W$$$ and $$$1 \le y_A \le y_B \le H$$$
  • $$$1 \le x_1 \le x_2 \le W$$$ and $$$1 \le y_1 \le y_2 \le H$$$
  • $$$1 \le S \le 20$$$
  • No cell belongs to more than one rectangle.
Output

The minimum expected value is an irreducible fraction $$$a/b$$$. Print $$$a \cdot b^{-1} \bmod (10^9 + 7)$$$, where $$$b^{-1}$$$ is the integer such that $$$b \cdot b^{-1} \equiv 1 \pmod{10^9 + 7}$$$. It can be shown that it always exists.

The minimum is taken over the real values, not over their remainders modulo $$$10^9 + 7$$$.

Examples
Input
3 4 3
1 1 4 3
2 1 2 3
3 1 3 2
3 3 3 3
Output
833333340
Input
1 3 2
1 1 3 1
1 1 2 1
3 1 3 1
Output
2
Note

Example 1. The rectangles have $$$3$$$, $$$2$$$ and $$$1$$$ cells. The path $$$(1, 1) \to (2, 1) \to (3, 1) \to (4, 1) \to (4, 2) \to (4, 3)$$$ goes through one cell of the first and one of the second, and its expected value is $$$\frac{1}{3} + \frac{1}{2} = \frac{5}{6}$$$. No path has a smaller expected value. Since $$$5 \cdot 6^{-1} \bmod (10^9 + 7) = 833\,333\,340$$$, that is the answer.

Example 2. There is only one path and it goes through all the cells of both rectangles, so it has exactly $$$2$$$ mines.