#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long dd = 1e5 + 7;
int g[dd], c[dd], v[dd], b[dd];
int main() {
  int n, m, r = 0, j;
  cin >> n >> m;
  for (long long i = (long long)1; i < (long long)n + 1; i++)
    scanf("%d", &g[i]);
  for (int i = 0; i < (long long)m; i++) scanf("%d", &v[i]);
  for (int i = 0; i < (long long)m; i++) {
    int b;
    scanf("%d", &b);
    for (j = (r + v[i] - 1) % n + 1, r = 0; c[j] < b; j = g[j]) {
      if (c[j] == 0) r++;
      c[j] = b, b--;
    }
    printf("%d\n", r);
  }
}
