#include <bits/stdc++.h>
using namespace std;
const int N = 100100, op = 1000000009;
int n;
int f[N], s[N], ls[N], rs[N], l[N], r[N];
pair<int, int> a[N], G[N];
int bcj(const int x) { return x == f[x] ? x : f[x] = bcj(f[x]); }
bool cmp(const int &A, const int &B) { return a[A].second < a[B].second; }
void init() {
  int k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; ++i)
    scanf("%d%d", &a[i].first, &a[i].second), s[i] = i;
  int A, B, C, D;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  for (int i = k + 1; i <= n; ++i)
    a[i].first = ((long long)a[i - 1].first * A + B) % op,
    a[i].second = ((long long)a[i - 1].second * C + D) % op, s[i] = i;
}
void work() {
  sort(a + 1, a + 1 + n);
  memset(f, 0, sizeof(f));
  sort(s + 1, s + 1 + n, cmp);
  for (int i = 1, L, R, now; i <= n; ++i) {
    now = s[i];
    f[now] = now;
    if (f[now - 1] == 0)
      L = 0, l[now] = a[now].first;
    else
      L = bcj(now - 1), f[L] = now, l[now] = l[L];
    if (f[now + 1] == 0)
      R = 0, r[now] = a[now].first;
    else
      R = bcj(now + 1), f[R] = now, r[now] = r[R];
    ls[now] = L, rs[now] = R;
    if (L == 0 && R == 0)
      G[now].first = G[now].second = 0;
    else if (R == 0)
      G[now].first = max(G[L].second + 1, G[L].first),
      G[now].second = G[L].first;
    else if (L == 0)
      G[now].first = max(G[R].second + 1, G[R].first),
      G[now].second = G[R].first;
    else {
      G[now].second = G[L].first + G[R].first;
      G[now].first = max(G[now].second, 1 + max(G[L].second + G[R].first,
                                                G[L].first + G[R].second));
    }
  }
}
pair<int, int> ask(const int z, const int x, const int y) {
  if (z == 0 || l[z] > y || r[z] < x) return make_pair(0, -1);
  if (x <= l[z] && r[z] <= y) return G[z];
  if (y < a[z].first) return ask(ls[z], x, y);
  if (x > a[z].first) return ask(rs[z], x, y);
  pair<int, int> L = ask(ls[z], x, y), R = ask(rs[z], x, y), now;
  now.second = L.first + R.first;
  now.first = max(now.second, 1 + max(L.first + R.second, L.second + R.first));
  return now;
}
void Gans() {
  int Q, x, y;
  for (scanf("%d", &Q); Q--;) {
    scanf("%d%d", &x, &y);
    printf("%d\n", ask(s[n], x, y).first);
  }
}
int main() {
  init();
  work();
  Gans();
  return 0;
}
