#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  point(int x = 0, int y = 0) : x(x), y(y) {}
};
struct node {
  node *lc, *rc;
  int l, r, mid;
  pair<int, int> f;
};
node tree[100005];
point p[100005];
node *root, *t0;
int n, k, m;
bool operator<(point a, point b) { return a.x < b.x; }
inline pair<int, int> update(pair<int, int> l, pair<int, int> r) {
  return make_pair(l.second + r.second,
                   max(l.first + r.second, l.second + r.first) + 1);
}
int find_max(int l, int r) {
  int i, pos;
  pos = l;
  for (i = l + 1; i <= r; ++i)
    if (p[i].y > p[pos].y) pos = i;
  return pos;
}
node *build(int l, int r) {
  if (l > r) return t0;
  int mid = find_max(l, r);
  node *x = &tree[mid];
  x->l = p[l].x, x->r = p[r].x, x->mid = p[mid].x;
  x->lc = build(l, mid - 1);
  x->rc = build(mid + 1, r);
  x->f = update(x->lc->f, x->rc->f);
  return x;
}
pair<int, int> query(node *pos, int l, int r) {
  if (pos == t0 || pos->r < l || pos->l > r) return t0->f;
  if (l <= pos->l && pos->r <= r) return pos->f;
  if (r < pos->mid) return query(pos->lc, l, r);
  if (l > pos->mid) return query(pos->rc, l, r);
  return update(query(pos->lc, l, r), query(pos->rc, l, r));
}
int main() {
  long long a, b, c, d;
  pair<int, int> ans;
  int i, l, r;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= k; ++i) scanf("%d%d", &p[i].x, &p[i].y);
  scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
  for (i = k + 1; i <= n; ++i)
    p[i] = point((p[i - 1].x * a + b) % 1000000009,
                 (p[i - 1].y * c + d) % 1000000009);
  sort(&p[1], &p[n + 1]);
  t0 = &tree[0];
  t0->f = make_pair(-1, 0);
  root = build(1, n);
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &l, &r);
    ans = query(root, l, r);
    printf("%d\n", max(ans.first, ans.second));
  }
  return 0;
}
