#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int f[N], g[N], v[N], b[N], res[N];
int main() {
  int n, m, ai;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &g[i]);
      f[i] = 0;
    }
    res[0] = 0;
    for (int i = 1; i <= m; i++) {
      scanf("%d", &v[i]);
      res[i] = 0;
    }
    for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= m; i++) {
      ai = ((v[i] + res[i - 1] - 1) % n) + 1;
      for (int j = ai, k = b[i]; f[j] < k && f[j] < n && k; j = g[j], k--) {
        if (!f[j]) res[i]++;
        f[j] = k;
      }
    }
    for (int i = 1; i <= m; i++) printf("%d\n", res[i]);
  }
  return 0;
}
