#include <bits/stdc++.h>
using namespace std;
struct pu {
  int x, y;
  int v, n;
  int a, b;
  int best;
  bool h;
  pu() {
    x = 0;
    y = 0;
    a = b = best = -1;
  }
  pu(int xx, int yy) {
    x = xx;
    y = yy;
    a = b = best = -1;
  }
};
bool operator<(const pu &a, const pu &b) { return a.x < b.x; }
int N, K, Q;
pu p[100010];
void init(int i) {
  if (p[i].best != -1) return;
  int a = p[i].a, b = p[i].b;
  if (a != -1) init(a);
  if (b != -1) init(b);
  if (b < a) swap(a, b);
  if (a == -1 && b == -1) {
    p[i].best = 0;
    p[i].h = false;
  } else if (a == -1 && b != -1) {
    p[i].best = p[b].best;
    p[i].h = !p[b].h;
  } else {
    p[i].best = p[a].best + p[b].best;
    p[i].h = !p[a].h || !p[b].h;
  }
  p[i].best += p[i].h;
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < (K); i++) scanf("%d%d", &p[i].x, &p[i].y);
  int a, b, c, d;
  const int MOD = 1000000009;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  for (int i = K; i < N; i++) {
    p[i].x = ((long long)a * p[i - 1].x + b) % MOD;
    p[i].y = ((long long)c * p[i - 1].y + d) % MOD;
  }
  sort(p, p + N);
  {
    stack<int> st;
    for (int i = 0; i < (N); i++) {
      while (!st.empty() && p[st.top()].y < p[i].y) st.pop();
      p[i].v = st.empty() ? -1 : st.top();
      if (!st.empty()) p[st.top()].b = i;
      st.push(i);
    }
  }
  {
    stack<int> st;
    for (int i = N - 1; i >= 0; i--) {
      while (!st.empty() && p[st.top()].y < p[i].y) st.pop();
      p[i].n = st.empty() ? -1 : st.top();
      if (!st.empty()) p[st.top()].a = i;
      st.push(i);
    }
  }
  for (int i = 0; i < (N); i++) init(i);
  scanf("%d", &Q);
  for (int q = 0; q < (Q); q++) {
    int L, R;
    scanf("%d%d", &L, &R);
    int erg = 0;
    int l = lower_bound(p, p + N, pu(L, 0)) - p;
    bool h1 = true, h2 = true;
    if (l < N) {
      int i = l;
      while (1) {
        if (p[i].n == -1 || p[p[i].n].x > R) break;
        if (p[i].b == -1) {
          h1 = !h1;
        } else {
          erg += p[p[i].b].best;
          h1 = !h1 || !p[p[i].b].h;
        }
        erg += h1;
        i = p[i].n;
      }
    }
    int r = upper_bound(p, p + N, pu(R, 0)) - p - 1;
    if (r >= 0) {
      int i = r;
      while (1) {
        if (p[i].v == -1 || p[p[i].v].x < L) break;
        if (p[i].a == -1) {
          h2 = !h2;
        } else {
          erg += p[p[i].a].best;
          h2 = !h2 || !p[p[i].a].h;
        }
        erg += h2;
        i = p[i].v;
      }
    }
    erg += !h1 || !h2;
    printf("%d\n", erg);
  }
  return 0;
}
