#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 233;
int pre[maxn][21], last[maxn], a[maxn], val[maxn];
int ch[maxn * 20], lc[maxn * 20], rc[maxn * 20], rt[maxn];
int cnt = 0;
void add(int l, int r, int& cur, int v) {
  cnt++;
  ch[cnt] = ch[cur] + 1;
  lc[cnt] = lc[cur];
  rc[cnt] = rc[cur];
  cur = cnt;
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (v <= mid)
    add(l, mid, lc[cur], v);
  else
    add(mid + 1, r, rc[cur], v);
}
int query(int l, int r, int x, int y, int R) {
  if (r <= R) return ch[y] - ch[x];
  if (l > R) return 0;
  int mid = (l + r) >> 1;
  return query(l, mid, lc[x], lc[y], R) + query(mid + 1, r, rc[x], rc[y], R);
}
int main() {
  int n, k;
  cin >> n >> k;
  memset(last, 0, sizeof(last));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pre[i][0] = last[a[i]];
    last[a[i]] = i;
  }
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i <= n; i++) pre[i][j] = pre[pre[i][j - 1]][j - 1];
  for (int i = 1; i <= n; i++) {
    int x = i, t = k;
    for (int j = 20; j >= 0; j--)
      if (t >= (1 << j)) {
        x = pre[x][j];
        t -= 1 << j;
      }
    val[i] = x;
  }
  for (int i = 1; i <= n; i++) {
    rt[i] = rt[i - 1];
    add(1, n, rt[i], val[i] + 1);
  }
  int q;
  cin >> q;
  int ans = 0;
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l = (l + ans) % n + 1;
    r = (r + ans) % n + 1;
    if (l > r) swap(l, r);
    ans = query(1, n, rt[l - 1], rt[r], l);
    printf("%d\n", ans);
  }
  return 0;
}
