#include <bits/stdc++.h>
using namespace std;
inline int rd() {
  int r;
  scanf("%d", &r);
  return r;
}
pair<int, int> A[200050];
int cnt, n, m, rt, a, b, c, d, k;
void GP(int &a, int &b, pair<int, int> P) { a = P.first, b = P.second; }
struct Node {
  int l, r, siz, key, F, G;
} tr[200050];
int up(int t) {
  tr[t].siz = tr[tr[t].l].siz + tr[tr[t].r].siz + 1;
  if (!tr[t].l && !tr[t].r) {
    tr[t].F = tr[t].G = 0;
    return t;
  }
  if (!tr[t].l) {
    tr[t].F = tr[tr[t].r].G;
    tr[t].G = tr[tr[t].r].F + 1;
    return t;
  }
  if (!tr[t].r) {
    tr[t].F = tr[tr[t].l].G;
    tr[t].G = tr[tr[t].l].F + 1;
    return t;
  }
  tr[t].F = tr[tr[t].l].G + tr[tr[t].r].G;
  tr[t].G =
      max(tr[tr[t].l].F + tr[tr[t].r].G, tr[tr[t].l].G + tr[tr[t].r].F) + 1;
  return t;
}
void build(int l, int r, int &t) {
  if (l > r) return;
  int now = -1, lo = 0;
  for (int _ = l; _ <= r; _++)
    A[_].second > now ? now = A[_].second, lo = _ : 0;
  tr[t = ++cnt].key = A[lo].second;
  build(l, lo - 1, tr[t].l);
  build(lo + 1, r, tr[t].r);
  up(t);
}
pair<int, int> spl(int t, int k) {
  int tmp;
  if (!k) return make_pair(0, t);
  if (k == tr[t].siz) return make_pair(t, 0);
  return tr[tr[t].l].siz + 1 <= k
             ? (GP(tr[t].r, tmp, spl(tr[t].r, k - tr[tr[t].l].siz - 1)), up(t),
                make_pair(t, tmp))
             : (GP(tmp, tr[t].l, spl(tr[t].l, k)), up(t), make_pair(tmp, t));
}
int mer(int first, int second) {
  if (!first || !second) return first + second;
  return tr[first].key > tr[second].key
             ? (tr[first].r = mer(tr[first].r, second), up(first))
             : (tr[second].l = mer(first, tr[second].l), up(second));
}
void solve() {
  for (int _ = k + 1; _ <= n; _++)
    A[_].first = (1LL * a * A[_ - 1].first + b) % 1000000009,
    A[_].second = (1LL * c * A[_ - 1].second + d) % 1000000009;
  sort(A + 1, A + n + 1);
  build(1, n, rt);
  m = rd();
  while (m--) {
    int ll = rd(), rr = rd(), r1, r2;
    pair<int, int> tmp;
    tmp.first = ll, tmp.second = 0;
    ll = (int)(lower_bound(A + 1, A + n + 1, tmp) - A) - 1;
    GP(r1, rt, spl(rt, ll));
    tmp.first = rr + 1, tmp.second = 0;
    rr = (int)(lower_bound(A + 1, A + n + 1, tmp) - A - 1) - ll;
    GP(rt, r2, spl(rt, rr));
    printf("%d\n", max(tr[rt].F, tr[rt].G));
    rt = mer(r1, rt);
    rt = mer(rt, r2);
  }
}
void init() {
  n = rd(), k = rd();
  for (int _ = 1; _ <= k; _++) A[_].first = rd(), A[_].second = rd();
  a = rd(), b = rd(), c = rd(), d = rd();
}
int main() {
  init();
  solve();
  return 0;
}
