#include <bits/stdc++.h>
using namespace std;
int x[100001], y[100001], mx[400001], id[400001];
int nn;
void sort1(int l, int r) {
  int X, id, i, j;
  i = l;
  j = r;
  id = ((l + r) >> 1);
  X = x[id];
  while (i <= j) {
    while (x[i] < X) ++i;
    while (X < x[j]) --j;
    if (i <= j) {
      swap(x[i], x[j]);
      swap(y[i], y[j]);
      ++i;
      --j;
    }
  }
  if (l < j) sort1(l, j);
  if (i < r) sort1(i, r);
}
void build(int v, int l, int r) {
  if (l == r) {
    id[v] = l;
    mx[v] = y[l];
  } else {
    int t = (l + r) / 2;
    build(2 * v, l, t);
    build(2 * v + 1, t + 1, r);
    if (mx[2 * v] > mx[2 * v + 1])
      id[v] = id[2 * v];
    else
      id[v] = id[2 * v + 1];
    mx[v] = max(mx[2 * v], mx[2 * v + 1]);
  }
  return;
}
int id_max(int v, int l, int r, int L, int R) {
  if (l == L && r == R) return id[v];
  int t = (l + r) / 2;
  if (R <= t) return id_max(2 * v, l, t, L, R);
  if (L > t) return id_max(2 * v + 1, t + 1, r, L, R);
  int id1 = id_max(2 * v, l, t, L, t), mx1 = y[id1],
      id2 = id_max(2 * v + 1, t + 1, r, t + 1, R), mx2 = y[id2];
  if (mx1 > mx2) return id1;
  return id2;
};
struct item {
  int key, priority, dp1, dp0;
  item *left, *right;
  item() {}
  ~item() {}
  item(int x, int y)
      : key(x), priority(y), left(NULL), right(NULL), dp0(0), dp1(0) {}
};
typedef item *pitem;
inline void upd(pitem &t) {
  if (t) {
    t->dp0 = 0;
    if (t->left) t->dp0 += t->left->dp1;
    if (t->right) t->dp0 += t->right->dp1;
    int k1, k2;
    k1 = k2 = 0;
    if (t->left) {
      k1 += 1 + t->left->dp0;
      k2 += t->left->dp1;
    }
    if (t->right) {
      k1 += t->right->dp1;
      k2 += 1 + t->right->dp0;
    }
    t->dp1 = max(k1, k2);
  }
  return;
}
pitem go(int l, int r) {
  int id = id_max(1, 1, nn, l, r);
  pitem a = new item(x[id], y[id]);
  if (l < id) a->left = go(l, id - 1);
  if (id < r) a->right = go(id + 1, r);
  upd(a);
  return a;
}
void merge(pitem &t, pitem l, pitem r) {
  if (!l || !r) {
    t = l ? l : r;
    return;
  }
  if (l->priority > r->priority)
    merge(l->right, l->right, r), t = l;
  else
    merge(r->left, l, r->left), t = r;
  upd(t);
  return;
}
void split(pitem t, pitem &l, pitem &r, int kk) {
  if (!t) {
    l = r = NULL;
    return;
  }
  if (t->key > kk)
    split(t->left, l, t->left, kk), r = t;
  else
    split(t->right, t->right, r, kk), l = t;
  upd(l);
  upd(r);
  return;
}
int main() {
  int n, k;
  cin >> n >> k;
  nn = n;
  for (int i = 1; i <= k; ++i) scanf("%d %d", &x[i], &y[i]);
  int a, b, c, d, md = 1000000009;
  cin >> a >> b >> c >> d;
  for (int i = k + 1; i <= n; ++i) {
    x[i] = (x[i - 1] * (long long)a + b) % md;
    y[i] = (y[i - 1] * (long long)c + d) % md;
  }
  sort1(1, n);
  build(1, 1, n);
  pitem MyTree = new (item);
  MyTree = go(1, n);
  int q;
  cin >> q;
  for (int it = 1; it <= q; ++it) {
    int l, r;
    cin >> l >> r;
    pitem t1, t2, t3;
    split(MyTree, t1, t2, l - 1);
    split(t2, t2, t3, r);
    if (t2)
      cout << t2->dp1 << endl;
    else
      cout << "0" << endl;
    merge(MyTree, t1, t2);
    merge(MyTree, MyTree, t3);
  }
  return 0;
}
