#include <bits/stdc++.h>
using namespace std;
struct DSU {
  int a[100010];
  int d[100010];
  char use[100010];
  DSU() {
    for (int i = 0; i < 100010; ++i) a[i] = i, d[i] = 0, use[i] = 0;
  };
  int get(int id) {
    if (a[id] == id) return id;
    int res = get(a[id]);
    d[id] += d[a[id]];
    a[id] = res;
    return a[id];
  }
  int link(int f, int s) {
    s = get(s);
    if (f != s) {
      a[f] = s;
      return 1;
    }
    return 0;
  }
} dsu;
int n, m;
int to[100010];
int v[100010];
int b[100010];
void solve() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> to[i];
  for (int i = 1; i <= m; ++i) cin >> v[i];
  for (int i = 1; i <= m; ++i) cin >> b[i];
  int res = 0;
  for (int i = 1; i <= m; ++i) {
    int id = (res + v[i] - 1) % n + 1;
    dsu.get(id);
    res = 0;
    int w = b[i] - dsu.d[id] - 1;
    id = dsu.a[id];
    while (w >= 0) {
      if (dsu.use[id]) break;
      ++res;
      dsu.use[id] = 1;
      int next = dsu.get(to[id]);
      dsu.d[id] = dsu.d[to[id]] + 1;
      dsu.a[id] = next;
      w -= dsu.d[id];
      id = next;
    }
    cout << res << "\n";
  }
}
int main() {
  solve();
  return 0;
}
