#include <bits/stdc++.h>
using namespace std;
const int modulo = 1000000009;
const int inf = 1000000000;
struct point {
  int x, y;
  bool operator<(const point &o) const { return x < o.x; }
  point(int _x = 0, int _y = 0) : x(_x), y(_y) {}
} p[100000];
int l[100001], r[100001], lch[100001], rch[100001], mid[100001];
pair<int, int> val[100001];
pair<int, int> combine(pair<int, int> a, pair<int, int> b) {
  pair<int, int> res;
  res.first = max(a.second + max(b.first, b.second),
                  max(a.first, a.second) + b.second) +
              1;
  res.second = max(a.first, a.second) + max(b.first, b.second);
  return res;
}
int buildTree(int l0, int r0) {
  static int top = 1;
  if (l0 >= r0) return 0;
  int now = top++;
  l[now] = l0;
  r[now] = r0;
  int loc = l0;
  for (int i = l0; i < r0; i++)
    if (p[i].y > p[loc].y) loc = i;
  mid[now] = loc;
  lch[now] = buildTree(l0, loc);
  rch[now] = buildTree(loc + 1, r0);
  val[now] = combine(val[lch[now]], val[rch[now]]);
  return now;
}
pair<int, int> solve(int now, int l0, int r0) {
  if (l0 == r0) return val[0];
  if (l0 == l[now] && r0 == r[now]) return val[now];
  if (l0 > mid[now]) return solve(rch[now], l0, r0);
  if (r0 <= mid[now]) return solve(lch[now], l0, r0);
  return combine(solve(lch[now], l0, mid[now]),
                 solve(rch[now], mid[now] + 1, r0));
}
int main() {
  int n, k, a, b, c, d;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) scanf("%d%d", &p[i].x, &p[i].y);
  scanf("%d%d%d%d", &a, &b, &c, &d);
  for (int i = k; i < n; i++) {
    p[i].x = (int)(((long long)p[i - 1].x * a + b) % modulo);
    p[i].y = (int)(((long long)p[i - 1].y * c + d) % modulo);
  }
  sort(p, p + n);
  val[0].first = 0;
  val[0].second = -inf;
  int root = buildTree(0, n);
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int L, R;
    scanf("%d%d", &L, &R);
    int t1 = lower_bound(p, p + n, point(L, 0)) - p;
    int t2 = lower_bound(p, p + n, point(R + 1, 0)) - p;
    pair<int, int> res = solve(root, t1, t2);
    printf("%d\n", max(res.first, res.second));
  }
  return 0;
}
