#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, b;
int g[N], v[N];
int cnt[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> g[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> v[i];
  }
  int res = 0;
  for (int i = 1; i <= m; i++) {
    cin >> b;
    b = min(b, n);
    int a = (v[i] + res - 1) % n + 1;
    res = 0;
    while (b > 0) {
      if (cnt[a] >= b) break;
      if (cnt[a] == 0) {
        res++;
      }
      cnt[a] = b;
      b--;
      a = g[a];
    }
    cout << res << '\n';
  }
}
