#include <bits/stdc++.h>
using namespace std;
const int N = 1.1e5;
int g[N], gd[N], a[N], b[N], v[N], res[N], vis[N], n, m;
int st[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", g + i), gd[i] = 1;
  for (int i = 1; i <= m; ++i) scanf("%d", v + i);
  for (int i = 1; i <= m; ++i) scanf("%d", b + i);
  for (int i = 1; i <= m; ++i) {
    a[i] = (v[i] + res[i - 1] - 1) % n + 1;
    int k = b[i], x = a[i];
    vector<int> along;
    bool loop = false;
    while (k > 0) {
      along.push_back(x);
      if (!st[x]) {
        st[x] = i;
        res[i]++;
      }
      vis[x] = i;
      if (vis[g[x]] == i) {
        loop = true;
        break;
      }
      k -= gd[x];
      x = g[x];
    }
    printf("%d\n", res[i]);
    for (int j = (int)along.size() - 1; j >= 0; --j) {
      int y = along[j];
      if (loop)
        g[y] = y;
      else if (st[g[y]]) {
        gd[y] += gd[g[y]];
        g[y] = g[g[y]];
      }
    }
  }
}
