#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 998244353;
long long qpow(long long x, long long n, long long m = MOD) {
  long long res = 1;
  for (; n; n >>= 1, x = x * x % m)
    if (n & 1) res = res * x % m;
  return res;
}
template <typename T>
void cmin(T &x, T y) {
  if (y < x) x = y;
}
template <typename T>
void cmax(T &x, T y) {
  if (y > x) x = y;
}
void purin_init() {}
int n, m;
int g[100005];
int v[100005];
int b[100005];
int vis[100005];
void purin_solve() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; ++i) vis[i] = 0;
    for (int i = 1; i <= n; ++i) scanf("%d", &g[i]);
    for (int i = 1; i <= m; ++i) scanf("%d", &v[i]);
    for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
    int res = 0;
    for (int i = 1; i <= m; ++i) {
      int a = (v[i] + res - 1) % n + 1;
      int k = b[i];
      int cres = 0;
      while (b[i]) {
        cres += (vis[a] == 0);
        if (vis[a] < b[i]) {
          vis[a] = b[i];
          a = g[a];
          --b[i];
        } else
          break;
      }
      printf("%d\n", cres);
      res = cres;
    }
  }
}
int main() {
  cout << fixed << setprecision(9);
  purin_init();
  purin_solve();
  return 0;
}
