#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 20;
const int INFINITE = INT_MIN;
const int MAXNUM = MAX;
template <typename T>
struct SegTree {
  struct SegTreeNode {
    T val;
    int idx;
    int addMark;
  };
  SegTreeNode nodes[MAXNUM << 2];
  T *arr;
  int istart, iend, maxIndex;
  SegTree() {}
  SegTree(T *arr1, int start, int end) : arr(arr1), istart(start), iend(end) {
    maxIndex = -1;
    build(0, arr, istart, iend);
  }
  void maintain(int root) {
    int left = root * 2 + 1, right = root * 2 + 2;
    if (nodes[left].val > nodes[right].val) {
      nodes[root].val = nodes[left].val;
      nodes[root].idx = nodes[left].idx;
    } else {
      nodes[root].val = nodes[right].val;
      nodes[root].idx = nodes[right].idx;
    }
  }
  void build(int root, T arr[], int istart, int iend) {
    nodes[root].addMark = 0;
    if (istart == iend) {
      if (root > maxIndex) maxIndex = root;
      nodes[root].val = arr[istart];
      nodes[root].idx = istart;
    } else {
      int mid = (istart + iend) / 2;
      build(root * 2 + 1, arr, istart, mid);
      build(root * 2 + 2, arr, mid + 1, iend);
      maintain(root);
    }
  }
  void pushDown(int root) { return; }
  struct Ans {
    T val;
    int idx;
    Ans(T a = 0, int b = 0) : val(a), idx(b) {}
  };
  Ans query(int qstart, int qend) {
    return query(0, istart, iend, qstart, qend);
  }
  Ans query(int root, int nstart, int nend, int qstart, int qend) {
    if (qstart > nend || qend < nstart) return Ans(T(-1), -1);
    if (qstart <= nstart && qend >= nend) {
      pushDown(root);
      return Ans(nodes[root].val, nodes[root].idx);
    }
    pushDown(root);
    int mid = (nstart + nend) / 2;
    Ans left = query(root * 2 + 1, nstart, mid, qstart, qend);
    Ans right = query(root * 2 + 2, mid + 1, nend, qstart, qend);
    if (left.idx == -1)
      return right;
    else if (right.idx == -1)
      return left;
    else {
      if (left.val > right.val)
        return left;
      else
        return right;
    }
  }
};
const long long MOD = 1e9 + 9 + 0.5;
vector<int> adj[MAX];
struct point {
  long long x, y;
  point(long long a = 0, long long b = 0) : x(a), y(b) {}
};
point ps[MAX];
struct node {
  int idx;
  node(int a = 0) : idx(a) {}
  bool operator<(const node &b) const { return ps[idx].y < ps[b.idx].y; }
  bool operator>(const node &b) const { return ps[idx].y > ps[b.idx].y; }
};
node ns[MAX];
int n, k;
long long a, b, c, d;
int m;
SegTree<node> tree;
struct T {
  int left, right;
  T(int a = 0, int b = 0) : left(a), right(b) {}
};
T tr[MAX];
int buildTree(int left, int right) {
  SegTree<node>::Ans tmp = tree.query(left, right);
  int arrPos = tmp.idx;
  int psPos = tmp.val.idx;
  if (left > right)
    return 0;
  else if (left == right)
    return psPos;
  else {
    int leftPos = buildTree(left, arrPos - 1);
    int rightPos = buildTree(arrPos + 1, right);
    tr[psPos].left = leftPos, tr[psPos].right = rightPos;
    return psPos;
  }
}
int dp[MAX][2];
int sol(int idx, int f) {
  auto &ele = dp[idx][f];
  if (ele != -1) return ele;
  if (f == 0) {
    if (tr[idx].left == 0 && tr[idx].right == 0)
      return ele = 0;
    else {
      ele = 0;
      if (tr[idx].left) {
        ele += max(sol(tr[idx].left, 0), sol(tr[idx].left, 1));
      }
      if (tr[idx].right) {
        ele += max(sol(tr[idx].right, 0), sol(tr[idx].right, 1));
      }
      return ele;
    }
  } else {
    if (tr[idx].left == 0 && tr[idx].right == 0)
      return ele = INT_MIN;
    else {
      if (tr[idx].left == 0) {
        return ele = 1 + sol(tr[idx].right, 0);
      } else if (tr[idx].right == 0) {
        return ele = 1 + sol(tr[idx].left, 0);
      } else {
        int u = tr[idx].left, v = tr[idx].right;
        return ele = max(1 + sol(u, 0) + max(sol(v, 0), sol(v, 1)),
                         1 + sol(v, 0) + max(sol(u, 0), sol(u, 1)));
      }
    }
  }
}
long long l, r;
int dp2[MAX][2];
int sol(int root, int f, int mask) {
  auto &ele = dp2[root][f];
  if (ele != -1) return ele;
  int left = tr[root].left, right = tr[root].right;
  if (mask == 3) {
    if (f == 0) {
      if (!left && !right)
        return ele = 0;
      else if (!left) {
        return ele = max(sol(right, 0, 2), sol(right, 1, 2));
      } else if (!right) {
        return ele = max(sol(left, 0, 1), sol(left, 1, 1));
      } else {
        return ele = max(sol(right, 0, 2), sol(right, 1, 2)) +
                     max(sol(left, 0, 1), sol(left, 1, 1));
      }
    } else {
      if (!left && !right)
        return ele = INT_MIN;
      else if (!left) {
        return ele = 1 + sol(right, 0, 2);
      } else if (!right) {
        return ele = 1 + sol(left, 0, 1);
      } else {
        return ele = max(1 + sol(left, 0, 1) +
                             max(sol(right, 0, 2), sol(right, 1, 2)),
                         1 + sol(right, 0, 2) +
                             max(sol(left, 0, 1), sol(left, 1, 1)));
      }
    }
  } else if (mask == 1) {
    if (f == 0) {
      if (!left && !right)
        return ele = 0;
      else if (!left) {
        return ele = max(sol(right, 0), sol(right, 1));
      } else if (!right) {
        return ele = max(sol(left, 0, 1), sol(left, 1, 1));
      } else {
        return ele = max(sol(left, 0, 1), sol(left, 1, 1)) +
                     max(sol(right, 0), sol(right, 1));
      }
    } else {
      if (!left && !right)
        return ele = INT_MIN;
      else if (!left) {
        return ele = 1 + sol(right, 0);
      } else if (!right) {
        return ele = 1 + sol(left, 0, 1);
      } else {
        return ele = max(
                   1 + sol(right, 0) + max(sol(left, 0, 1), sol(left, 1, 1)),
                   1 + sol(left, 0, 1) + max(sol(right, 0), sol(right, 1)));
      }
    }
  } else {
    if (f == 0) {
      if (!left && !right)
        return ele = 0;
      else if (!left) {
        return ele = max(sol(right, 0, 2), sol(right, 1, 2));
      } else if (!right) {
        return ele = max(sol(left, 0), sol(left, 1));
      } else {
        return ele = max(sol(left, 0), sol(left, 1)) +
                     max(sol(right, 0, 2), sol(right, 1, 2));
      }
    } else {
      if (!left && !right)
        return ele = INT_MIN;
      else if (!left) {
        return ele = 1 + sol(right, 0, 2);
      } else if (!right) {
        return ele = 1 + sol(left, 0);
      } else {
        return ele = max(
                   1 + sol(right, 0, 2) + max(sol(left, 0), sol(left, 1)),
                   1 + sol(left, 0) + max(sol(right, 0, 2), sol(right, 1, 2)));
      }
    }
  }
}
int go(int root) {
  while (root) {
    if (ps[root].x < l)
      root = tr[root].right;
    else if (ps[root].x > r)
      root = tr[root].left;
    else
      break;
  }
  if (!root)
    return 0;
  else {
    vector<pair<int, int> > lres, rres;
    int lr = tr[root].left, rr = tr[root].right;
    vector<pair<int, int> > ltmp, rtmp;
    ltmp.push_back({root, 1});
    while (lr) {
      if (ps[lr].x >= l) {
        ltmp.push_back({lr, 1});
        lr = tr[lr].left;
      } else {
        ltmp.push_back({lr, 0});
        lr = tr[lr].right;
      }
    }
    int prev = -1;
    for (int i = 0; i < ltmp.size(); i++) {
      auto &ele = ltmp[i];
      if (ele.second == 1) {
        dp2[ele.first][0] = dp2[ele.first][1] = -1;
        if (prev != -1) {
          lres.push_back({prev, tr[prev].left});
          tr[prev].left = ele.first;
          prev = -1;
        }
        if (i < (int)ltmp.size() - 1 && ltmp[i + 1].second == 0)
          prev = ele.first;
      }
    }
    if (prev != -1) {
      lres.push_back({prev, tr[prev].left});
      tr[prev].left = 0;
    }
    rtmp.push_back({root, 1});
    while (rr) {
      if (ps[rr].x <= r) {
        rtmp.push_back({rr, 1});
        rr = tr[rr].right;
      } else {
        rtmp.push_back({rr, 0});
        rr = tr[rr].left;
      }
    }
    prev = -1;
    for (int i = 0; i < rtmp.size(); i++) {
      auto &ele = rtmp[i];
      if (ele.second == 1) {
        dp2[ele.first][0] = dp2[ele.first][1] = -1;
        if (prev != -1) {
          rres.push_back({prev, tr[prev].right});
          tr[prev].right = ele.first;
          prev = -1;
        }
        if (i < (int)rtmp.size() - 1 && rtmp[i + 1].second == 0)
          prev = ele.first;
      }
    }
    if (prev != -1) {
      rres.push_back({prev, tr[prev].right});
      tr[prev].right = 0;
    }
    int ans = max(sol(root, 0, 3), sol(root, 1, 3));
    for (int i = 0; i < lres.size(); i++) {
      auto &ele = lres[i];
      tr[ele.first].left = ele.second;
    }
    for (int i = 0; i < rres.size(); i++) {
      auto &ele = rres[i];
      tr[ele.first].right = ele.second;
    }
    return ans;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) scanf("%lld%lld", &ps[i].x, &ps[i].y);
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  for (int i = k + 1; i <= n; i++) {
    ps[i].x = (a * ps[i - 1].x + b) % MOD;
    ps[i].y = (c * ps[i - 1].y + d) % MOD;
  }
  for (int i = 1; i <= n; i++) ns[i].idx = i;
  sort(ns + 1, ns + n + 1,
       [](const node &a, const node &b) { return ps[a.idx].x < ps[b.idx].x; });
  tree = SegTree<node>(ns, 1, n);
  int root = buildTree(1, n);
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int f = 0; f < 2; f++) sol(i, f);
  }
  dp[0][0] = 0, dp[0][1] = INT_MIN;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld", &l, &r);
    int ans = go(root);
    printf("%d\n", ans);
  }
  return 0;
}
