#include <bits/stdc++.h>
using namespace std;
struct arr {
  int x, y;
  bool operator<(const arr &o) const { return x < o.x; }
} p[100010];
struct brr {
  int l, r, v;
} t[100010];
int n, k, tot, v[100010], m, l, r;
long long a, b, c, d;
pair<int, int> g[100010];
pair<int, int> upd(pair<int, int> a, pair<int, int> b) {
  pair<int, int> c;
  c.first = c.second = 0;
  if (a.first >= 0 && b.first >= 0) {
    c.first = max(a.first, a.second) + max(b.first, b.second);
    c.second = max(max(a.first, a.second) + b.first,
                   max(b.first, b.second) + a.first) +
               1;
  } else {
    if (a.first < 0) {
      c.first = max(b.first, b.second);
      c.second = b.first + 1;
    } else {
      c.first = max(a.first, a.second);
      c.second = a.first + 1;
    }
  }
  return c;
}
int build(int l, int r) {
  if (l > r) return 0;
  int x = ++tot;
  t[x].v = l;
  for (int i = l + 1; i <= r; i++)
    if (p[i].y > p[t[x].v].y) t[x].v = i;
  t[x].l = build(l, t[x].v - 1), t[x].r = build(t[x].v + 1, r);
  g[x] = upd(g[t[x].l], g[t[x].r]);
  return x;
}
pair<int, int> ask(int s, int l, int r, int x, int y) {
  if (x > y) return make_pair(-1, 0);
  if (l == x && r == y) return g[s];
  if (t[s].v < x) return ask(t[s].r, t[s].v + 1, r, x, y);
  if (t[s].v > y) return ask(t[s].l, l, t[s].v - 1, x, y);
  return upd(ask(t[s].l, l, t[s].v - 1, x, t[s].v - 1),
             ask(t[s].r, t[s].v + 1, r, t[s].v + 1, y));
}
int main() {
  pair<int, int> e;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) scanf("%d%d", &p[i].x, &p[i].y);
  scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
  for (int i = k + 1; i <= n; i++)
    p[i].x = (p[i - 1].x * a + b) % 1000000009,
    p[i].y = (p[i - 1].y * c + d) % 1000000009;
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) v[i] = p[i].x;
  g[0].first = -1;
  build(1, n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l, &r);
    l = lower_bound(v + 1, v + n + 1, l) - v;
    r = upper_bound(v + 1, v + n + 1, r) - v - 1;
    e = ask(1, 1, n, l, r);
    printf("%d\n", max(e.first, e.second));
  }
  return 0;
}
