#include <bits/stdc++.h>
using namespace std;
int g[100009], n, m, b[100009], v[100009], res[100009], a[100009], u[100009];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &g[i]);
  for (int i = 0; i < m; i++) scanf("%d", &v[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]);
  for (int i = 0; i < m; i++) {
    a[i] = (v[i] + (!i ? 0 : res[i - 1]) - 1) % n;
    while (b[i]) {
      if (b[i] <= u[a[i]]) break;
      if (!u[a[i]]) res[i]++;
      u[a[i]] = b[i];
      b[i]--;
      a[i] = g[a[i]] - 1;
    }
    printf("%d\n", res[i]);
  }
  return 0;
}
