#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, m, par[MAXN], go[MAXN], nex[MAXN];
int arr[MAXN], b[MAXN];
bool mark[MAXN];
int get_par(int v) {
  if (!par[v]) return v;
  int local = par[v];
  par[v] = get_par(local);
  go[v] += go[local];
  return par[v];
}
bool merge(int v, int u) {
  v = get_par(v);
  if (v == get_par(u)) return false;
  go[v]++;
  par[v] = u;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> nex[i];
  for (int i = 1; i <= m; i++) cin >> arr[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  int res = 0;
  for (int i = 1; i <= m; i++) {
    int st = (arr[i] + res - 1) % n + 1;
    res = 0;
    b[i]--;
    if (!mark[st]) {
      mark[st] = true;
      res++;
    }
    while (true) {
      get_par(st);
      int dist = go[st];
      if (b[i] <= dist) break;
      st = get_par(st);
      if (!mark[nex[st]]) {
        mark[nex[st]] = true;
        res++;
      }
      if (!merge(st, nex[st])) break;
      st = nex[st];
      b[i] -= dist + 1;
    }
    cout << res << '\n';
  }
  cin >> n;
  return 0;
}
