#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const int INF = 1000000007;
struct Gao {
  int p[MAXN], q[MAXN];
  bool r[MAXN];
  void init(int n) {
    for (int i = 0; i <= n; ++i) {
      p[i] = 0;
      q[i] = 1;
      r[i] = true;
    }
  }
  void next(int i) {
    if (p[i] == i) {
    } else if (!r[p[i]]) {
      next(p[i]);
      q[i] = q[i] + q[p[i]];
      p[i] = p[p[i]];
    }
  }
  void kill(int i) {
    next(i);
    r[i] = false;
  }
} s;
int main() {
  int n, m, c;
  static int a[MAXN], b[MAXN];
  scanf("%d%d", &n, &m);
  s.init(n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &s.p[i]);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &b[i]);
  }
  c = 0;
  for (int i = 1; i <= m; ++i) {
    a[i] = ((a[i] + c - 1) % n) + 1;
    c = 0;
    while (true) {
      if (!s.r[a[i]]) {
        s.next(a[i]);
        b[i] -= s.q[a[i]];
        a[i] = s.p[a[i]];
      }
      if (!s.r[a[i]] || s.p[a[i]] == a[i] || b[i] <= 0) {
        break;
      } else {
        ++c;
        s.kill(a[i]);
      }
    }
    printf("%d\n", c);
  }
  return 0;
}
