#include <bits/stdc++.h>
int n, m, v[100010], g[100010], b[100010], a, fa[100010], len[100010], ans,
    hv[100010], cnt;
int getfa(int x, int ss) {
  if (hv[x] == ss) {
    len[x] = 10000000;
    return x;
  }
  hv[x] = ss;
  int ff = fa[x];
  if (fa[x] != x) {
    fa[x] = getfa(fa[x], ss);
    len[x] += len[ff];
    if (len[x] > 10000000) len[x] = 10000000;
  }
  return fa[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &g[i]), fa[i] = i;
  for (int i = 0; i < m; i++) scanf("%d", &v[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  memset(len, 0, sizeof len);
  a = cnt = 0;
  for (int i = 0; i < m; i++) {
    ans = 0;
    for (a = (a + v[i] - 1) % n + 1; b[i] > 0;
         len[a] = 1, a = fa[a] = g[a], b[i]--, ans++) {
      getfa(a, ++cnt);
      b[i] -= len[a];
      a = fa[a];
      if (b[i] <= 0) break;
    }
    a = ans;
    printf("%d\n", ans);
  }
  return 0;
}
