#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> g(n), v(m), b(m);
  for (auto &i : g) cin >> i;
  for (auto &i : v) cin >> i;
  for (auto &i : b) cin >> i;
  int res = 0;
  vector<bool> news(n, false);
  vector<int> x(n, 1);
  for (int i = 1; i <= m; ++i) {
    int a = (v[i - 1] + res - 1) % n + 1;
    int rating = b[i - 1] >= n ? n : b[i - 1];
    int ctr = 0;
    if (!news[a - 1]) {
      news[a - 1] = 1;
      ctr++;
    }
    int temp = a;
    while (rating) {
      rating -= x[a - 1];
      if (rating <= 0) break;
      temp = g[a - 1];
      if (!news[temp - 1]) {
        news[temp - 1] = 1;
        ctr++;
      }
      x[a - 1] += x[temp - 1];
      g[a - 1] = g[temp - 1];
      a = temp;
    }
    res = ctr;
    cout << ctr << '\n';
  }
  return 0;
}
