#include <bits/stdc++.h>
using namespace std;
const int NN = 100100;
const int MOD = 1000000009;
int lft[NN], rgt[NN], first[NN], second[NN], a[NN][2], L[NN], R[NN];
pair<int, int> p[NN];
void update(int *a, int *b) {
  if (b == NULL) return;
  a[1] = max(a[0] + b[0] + 1, a[1] + max(b[0], b[1]));
  a[0] = a[0] + max(b[0], b[1]);
}
void build(int u) {
  if (lft[u]) build(lft[u]), update(a[u], a[lft[u]]);
  if (rgt[u]) build(rgt[u]), update(a[u], a[rgt[u]]);
  L[u] = R[u] = first[u];
  if (lft[u]) L[u] = L[lft[u]];
  if (rgt[u]) R[u] = R[rgt[u]];
}
int *calc(int u, int st, int ed) {
  if (ed < L[u] || R[u] < st) return NULL;
  if (st <= L[u] && R[u] <= ed) return a[u];
  if (st <= first[u] && first[u] <= ed) {
    int *c = new int[2];
    c[0] = c[1] = 0;
    if (lft[u]) update(c, calc(lft[u], st, ed));
    if (rgt[u]) update(c, calc(rgt[u], st, ed));
    return c;
  }
  if (lft[u] && ed < first[u]) return calc(lft[u], st, ed);
  if (rgt[u] && st > first[u]) return calc(rgt[u], st, ed);
  return NULL;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) scanf("%d%d", &p[i].first, &p[i].second);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = k + 1; i <= n; i++) {
    p[i].first = ((long long)a * p[i - 1].first + b) % MOD;
    p[i].second = ((long long)c * p[i - 1].second + d) % MOD;
  }
  sort(p + 1, p + n + 1);
  stack<int> st;
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    ++cur;
    first[cur] = p[i].first;
    second[cur] = p[i].second;
    while (!st.empty() && second[st.top()] < p[i].second) {
      lft[cur] = st.top();
      st.pop();
    }
    if (!st.empty()) rgt[st.top()] = cur;
    st.push(cur);
  }
  int root = -1;
  while (!st.empty()) root = st.top(), st.pop();
  build(root);
  int q, l, r;
  for (scanf("%d", &q); q--;) {
    scanf("%d%d", &l, &r);
    int *t = calc(root, l, r);
    if (t == NULL)
      puts("0");
    else
      printf("%d\n", max(t[0], t[1]));
  }
  return 0;
}
