#include <bits/stdc++.h>
using namespace ::std;
const int maxn = 1e5 + 500;
const int inf = 1e9 + 800;
pair<int, int> f[maxn];
int res = 0;
int v[maxn];
int b[maxn];
bool fir[maxn];
int vis[maxn];
vector<int> vec;
void dfs(int a, int b) {
  if (b <= 0 || vis[a] != 0) {
    int p = 0;
    if (vis[a]) p = inf;
    for (int i = 0; i < (int)vec.size(); i++) {
      int v = vec[i];
      f[v].first = a;
      f[v].second = vis[v] - b + p;
      vis[v] = 0;
    }
    vec.clear();
    return;
  }
  vec.push_back(a);
  vis[a] = b;
  res += (!fir[a]);
  fir[a] = 1;
  dfs(f[a].first, b - f[a].second);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> f[i].first;
    f[i].second = 1;
  }
  for (int i = 1; i <= m; i++) cin >> v[i];
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    b[i] = min(b[i], n);
  }
  for (int i = 1; i <= m; i++) {
    int a = (v[i] + res - 1) % n + 1;
    res = 0;
    dfs(a, b[i]);
    cout << res << endl;
  }
}
