#include <bits/stdc++.h>
using namespace std;
const int MODER = 1000000009;
const int MAXN = 100000;
int n, k;
struct Point {
  int x, y;
} a[MAXN + 10];
struct Node {
  int l, r;
  Node *lChild, *rChild;
  int v0, v1;
} tree[MAXN + 10];
Node* build(int l, int r) {
  if (l > r) return &tree[0];
  int id = max_element(a + l, a + r + 1,
                       [](Point a, Point b) { return a.y < b.y; }) -
           a;
  tree[id].l = a[l].x;
  tree[id].r = a[r].x;
  if (l < r) {
    tree[id].lChild = build(l, id - 1);
    tree[id].rChild = build(id + 1, r);
    tree[id].v0 = tree[id].lChild->v1 + tree[id].rChild->v1;
    tree[id].v1 = max(tree[id].lChild->v0 + tree[id].rChild->v1,
                      tree[id].lChild->v1 + tree[id].rChild->v0) +
                  1;
    tree[id].v1 = max(tree[id].v1, tree[id].v0);
  }
  return &tree[id];
}
pair<int, int> query(Node* x, int l, int r) {
  if (l <= x->l && x->r <= r) return make_pair(x->v0, x->v1);
  if (l > x->r || r < x->l) return make_pair(-1, 0);
  if (a[x - tree].x < l) return query(x->rChild, l, r);
  if (a[x - tree].x > r) return query(x->lChild, l, r);
  pair<int, int> la = query(x->lChild, l, r), ra = query(x->rChild, l, r);
  return make_pair(la.second + ra.second,
                   max(la.first + ra.second, la.second + ra.first) + 1);
}
int main() {
  tree[0].v0 = -1;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) scanf("%d%d", &a[i].x, &a[i].y);
  long A, B, C, D;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  for (int i = k + 1; i <= n; i++)
    a[i].x = (A * (long long)a[i - 1].x + B) % MODER,
    a[i].y = (C * (long long)a[i - 1].y + D) % MODER;
  sort(a + 1, a + 1 + n, [](Point a, Point b) { return a.x < b.x; });
  Node* root = build(1, n);
  int qN;
  scanf("%d", &qN);
  while (qN--) {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%d\n", query(root, l, r).second);
  }
  return 0;
}
