#include <bits/stdc++.h>
int x4[4] = {0, 0, -1, 1};
int y4[4] = {-1, 1, 0, 0};
int x8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int y8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
int n, m;
int g[100005];
int res;
int v[100005];
int b[100005];
int c[100005];
int visited[100005];
void startDay(int day) {
  int a = (v[day] + res - 1) % n + 1;
  res = 0;
  while (b[day] > visited[a]) {
    if (!visited[a]) res++;
    visited[a] = b[day];
    b[day]--;
    a = g[a];
  }
  printf("%d\n", res);
}
int main() {
  memset(visited, 0, sizeof(visited));
  res = 0;
  scanf("%d %d", &n, &m);
  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]);
  for (int i = 1; i <= m; i++) startDay(i);
  return 0;
}
