time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In some country live wizards. They love to build cities and roads.

The country used to have k cities, the j-th city (1 ≤ j ≤ k) was located at a point (xj, yj). It was decided to create another n - k cities. And the i-th one (k < i ≤ n) was created at a point with coordinates (xi, yi):

• xi = (a·xi - 1 + bmod (109 + 9)
• yi = (c·yi - 1 + dmod (109 + 9)

Here a, b, c, d are primes. Also, a ≠ c, b ≠ d.

After the construction of all n cities, the wizards have noticed something surprising. It turned out that for every two different cities i and j, xi ≠ xj and yi ≠ yj holds.

The cities are built, it's time to build roads! It was decided to use the most difficult (and, of course, the most powerful) spell for the construction of roads. Using this spell creates a road between the towns of u, v (yu > yv) if and only if for any city w which lies strictly inside the corner at the point u, v (see below), there is a city s that does not lie in the corner, which is located along the x-coordinate strictly between w and u and simultaneously ys > yv.

A corner on the points p2(x2, y2), p1(x1, y1) (y1 < y2) is the set of points (x, y), for which at least one of the two conditions is fulfilled:

• min(x1, x2) ≤ x ≤ max(x1, x2) and y ≥ y1
• y1 ≤ y ≤ y2 and (x - x2)·(x1 - x2) ≥ 0
The pictures showing two different corners

In order to test the spell, the wizards will apply it to all the cities that lie on the x-coordinate in the interval [L, R]. After the construction of roads the national government wants to choose the maximum number of pairs of cities connected by the road, so that no city occurs in two or more pairs. Your task is for each m offered variants of values L, R to calculate the maximum number of such pairs after the construction of the roads. Please note that the cities that do not lie in the interval [L, R] on the x-coordinate, do not affect the construction of roads in any way.

Input

The first line contains two space-separated integers n, k (1 ≤ k ≤ n ≤ 105, k ≤ 30). Next k lines contain coordinates of the cities' location points from the first to the k-th one. The j-th line contains space-separated pair of integers xj, yj (0 ≤ xj, yj < 109 + 9) — coordinates of the j-th city.

The next line contains space-separated integers a, b, c, d (2 ≤ a, b, c, d < 109 + 9). It is guaranteed that those numbers are prime and also that a ≠ c, b ≠ d.

It's guaranteed, that for every two different cities i and j, xi ≠ xj and yi ≠ yj holds.

The next line contains integer m (1 ≤ m ≤ 105) — the number of variants to build the roads. Next m lines contain pairs of space-separated integers Li, Ri (0 ≤ Li ≤ Ri < 109 + 9) — the variants of choosing the cities to build the roads.

Output

For any pair of numbers Li, Ri print the answer to the problem on a single line. Print the answers for the pairs in the order, in which the pairs are given in the input data.

Examples
Input
6 60 01 12 23 34 45 52 3 3 240 51 42 33 3
Output
3210
Input
6 10 03 5 23917 1140 10000000080 10100 150200 10000
Output
2101
Note

In the first sample the roads connect the cities in a chain in the order of increasing of x.

In the second sample the remaining 5 cities will be located at points (5,  11); (20,  263098); (65,  292514823); (200,  76958738); (605,  622120197).