#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> g(n + 1);
  vector<int> v(m + 1);
  vector<int> res(m + 1);
  vector<int> b(m + 1);
  vector<int> a(m + 1);
  vector<int> dayb(n + 1);
  vector<int> pol(n + 1);
  for (int i = 1; i <= n; ++i) cin >> g[i];
  for (int i = 1; i <= m; ++i) cin >> v[i];
  for (int i = 1; i <= m; ++i) cin >> b[i];
  for (int i = 1; i <= m; ++i) {
    a[i] = ((v[i] + res[i - 1] - 1) % n) + 1;
    for (int j = a[i]; dayb[j] < b[i] && b[i] >= 0; j = g[j], --b[i]) {
      if (!pol[j]) {
        pol[j] = true;
        ++res[i];
      }
      dayb[j] = b[i];
    }
  }
  for (int i = 1; i <= m; ++i) cout << res[i] << endl;
  return 0;
}
