#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
inline int read() {
  int s = 0, w = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
int n, Q, f[N], a[N], Ans1[N], Ans2[N], tag[N];
int head[N], maxE;
struct Edge {
  int nxt, to;
} e[N << 1];
inline void Add(int u, int v) {
  e[++maxE].nxt = head[u];
  head[u] = maxE;
  e[maxE].to = v;
}
vector<int> G[N];
void DFS(int x, int fa, int w) {
  for (auto i : G[x]) tag[i] = w;
  for (register int i = 1; i <= Q; i++) {
    if (!tag[i]) continue;
    Ans1[i] += w - tag[i];
    Ans2[i]++;
    i += a[x], i--;
  }
  for (register int i = head[x]; i; i = e[i].nxt) DFS(e[i].to, x, w + 1);
  for (auto i : G[x]) tag[i] = 0;
}
signed main() {
  n = read(), Q = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  for (register int i = 2; i <= n; i++) f[i] = read(), Add(f[i], i);
  for (register int i = 1; i <= Q; i++) {
    int x = read();
    G[x].emplace_back(i);
  }
  DFS(1, 0, 1);
  for (register int i = 1; i <= Q; i++) printf("%d %d\n", Ans1[i], Ans2[i]);
  return 0;
}
