#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 9;
const int maxn = 110000;
int n, Q;
struct Tpair {
  int x, y;
  Tpair(int _x = 0, int _y = 0) { x = _x, y = _y; }
  inline bool operator<(const Tpair &b) const {
    return x != b.x ? x < b.x : y < b.y;
  }
  inline bool operator!=(const Tpair &b) const { return x != b.x || y != b.y; }
} A[maxn];
inline Tpair comb(const Tpair &a, const Tpair &b) {
  return Tpair(a.x + b.x + max(a.y - a.x, b.y - b.x) + 1, a.x + b.x);
}
struct Tdtr {
  Tdtr *l, *r;
  int x, y, t;
  Tpair F;
  Tpair match(int a, int b) {
    if (a == b) return Tpair(0, -1e6);
    if (x == a && y == b) return F;
    if (a + 1 == b && a == t) return Tpair(0, 0);
    return b <= t  ? l->match(a, b)
           : a > t ? r->match(a, b)
                   : comb(l->match(a, t), r->match(t + 1, b));
  }
} * Dt, *Null;
struct Tmemory {
  int n;
  Tdtr buf[maxn];
  inline Tdtr *operator()() { return buf + n++; }
} newS;
namespace Ninit {
int K, a, b, c, d;
Tdtr *build(int x, int y) {
  if (x == y) return Null;
  Tdtr *p = newS();
  p->x = x, p->y = y;
  if (x + 1 == y) return p;
  int i;
  for (p->t = i = x; i < y; ++i)
    if (A[p->t].y < A[i].y) p->t = i;
  p->l = build(x, p->t), p->r = build(p->t + 1, y);
  p->F = comb(p->l->F, p->r->F);
  return p;
}
void init() {
  int i;
  scanf("%d%d", &n, &K);
  for (i = 0; i < K; ++i) scanf("%d%d", &A[i].x, &A[i].y);
  scanf("%d%d%d%d", &a, &b, &c, &d);
  for (i = K; i < n; ++i) {
    A[i].x = ((long long)A[i - 1].x * a + b) % P;
    A[i].y = ((long long)A[i - 1].y * c + d) % P;
  }
  sort(A, A + n);
  Null = newS(), Null->F = Tpair(0, -1e6);
  Dt = build(0, n);
}
}  // namespace Ninit
namespace Nsolve {
void solve() {
  int li, ri;
  for (cin >> Q; Q; --Q) {
    scanf("%d%d", &li, &ri);
    li = lower_bound(A, A + n, Tpair(li, 0)) - A;
    ri = lower_bound(A, A + n, Tpair(ri + 1, 0)) - A;
    printf("%d\n", Dt->match(li, ri).x);
  }
}
}  // namespace Nsolve
int main() {
  Ninit::init();
  Nsolve::solve();
  return 0;
}
