#include <bits/stdc++.h>
using namespace std;
int visited[100003];
int main() {
  int n, m;
  cin >> n >> m;
  memset(visited, 0, sizeof(visited));
  int stud[100003], dis[100003], v[100003], b[100003];
  for (int i = 1; i <= n; i++) {
    cin >> stud[i];
    dis[i] = 1;
  }
  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 ai = (v[i] + res - 1) % n + 1, c = 0;
    if (visited[ai] == 0) {
      c++;
      visited[ai] = 1;
    }
    int nx = ai;
    while (b[i] > 0) {
      b[i] -= dis[ai];
      if (b[i] <= 0) {
        break;
      }
      nx = stud[ai];
      if (visited[nx] == 0) {
        visited[nx] = 1;
        c++;
      }
      stud[ai] = stud[nx];
      dis[ai] += dis[nx];
      ai = nx;
    }
    cout << c << '\n';
    res = c;
  }
  return 0;
}
