#include <bits/stdc++.h>
const int N = 100001;
int i, n, m, g[N], v[N], b[N], res[N], c[N], a;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &g[i]);
  for (i = 1; i <= m; i++) scanf("%d", &v[i]);
  for (i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (i = 1; i <= m; i++) {
    for (a = (v[i] + res[i - 1] - 1) % n + 1; b[i] > c[a]; a = g[a]) {
      if (c[a] == 0) res[i]++;
      c[a] = b[i];
      b[i]--;
    }
    printf("%d\n", res[i]);
  }
}
