#include <bits/stdc++.h>
using namespace std;
struct Point {
  int X, Y;
};
bool operator<(Point A, Point B) { return A.X < B.X; }
struct AnsType {
  int DP0, DP1;
};
AnsType operator+(AnsType A, AnsType B) {
  int DP0 = A.DP1 + B.DP1, DP1 = max(A.DP0 + B.DP1, A.DP1 + B.DP0) + 1;
  return (AnsType){DP0, max(DP0, DP1)};
}
struct Node {
  int Left, Right, Mid;
  AnsType Opt;
  Node *Lc, *Rc;
};
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return X;
}
const int Mod = 1000000009;
const int inf = 1000000000;
Point P[100000];
Node *null;
int DP[17][100000], Log[131072];
int GetMax(int L, int R) {
  int T = Log[R - L + 1], a = DP[T][L], b = DP[T][R - (1 << T) + 1];
  return (P[a].Y > P[b].Y) ? a : b;
}
Node *Build(int L, int R) {
  if (L > R) return null;
  Node *P = new Node;
  P->Left = L;
  P->Right = R;
  P->Mid = GetMax(L, R);
  P->Lc = Build(L, P->Mid - 1);
  P->Rc = Build(P->Mid + 1, R);
  P->Opt = P->Lc->Opt + P->Rc->Opt;
  return P;
}
int Find_0(int N, int X) {
  if (P[N - 1].X < X) return N;
  int Left = 0, Right = N - 1;
  while (Left < Right) {
    int Mid = (Left + Right) / 2;
    if (P[Mid].X < X)
      Left = Mid + 1;
    else
      Right = Mid;
  }
  return Left;
}
int Find_1(int N, int X) {
  if (P[0].X > X) return -1;
  int Left = 0, Right = N - 1;
  while (Left < Right) {
    int Mid = (Left + Right + 1) / 2;
    if (P[Mid].X <= X)
      Left = Mid;
    else
      Right = Mid - 1;
  }
  return Left;
}
AnsType Get(Node *P, int L, int R) {
  if (L > R) return (AnsType){-inf, 0};
  if (P->Left == L && P->Right == R) return P->Opt;
  if (R < P->Mid) return Get(P->Lc, L, R);
  if (L > P->Mid) return Get(P->Rc, L, R);
  return Get(P->Lc, L, P->Mid - 1) + Get(P->Rc, P->Mid + 1, R);
}
int main() {
  int N = Get(), K = Get();
  for (int i = 0; i < K; i++) {
    P[i].X = Get();
    P[i].Y = Get();
  }
  int a = Get(), b = Get(), c = Get(), d = Get();
  for (int i = K; i < N; i++) {
    P[i].X = ((long long)P[i - 1].X * a + b) % Mod;
    P[i].Y = ((long long)P[i - 1].Y * c + d) % Mod;
  }
  sort(P, P + N);
  for (int i = 0; i < N; i++) DP[0][i] = i;
  for (int i = 1, Len = 2; Len <= N; i++, Len *= 2)
    for (int j = 0; j <= N - Len; j++)
      if (P[DP[i - 1][j]].Y > P[DP[i - 1][j + Len / 2]].Y)
        DP[i][j] = DP[i - 1][j];
      else
        DP[i][j] = DP[i - 1][j + Len / 2];
  for (int i = 0; i < 17; i++)
    for (int j = (1 << i); j < (1 << (i + 1)); j++) Log[j] = i;
  null = new Node;
  null->Opt = (AnsType){-inf, 0};
  Node *Root = Build(0, N - 1);
  int Query = Get();
  while (Query--) {
    int L = Find_0(N, Get()), R = Find_1(N, Get());
    printf("%d\n", Get(Root, L, R).DP1);
  }
  return 0;
}
