#include <bits/stdc++.h>
using namespace std;
int n, q, fa[66666], aa[66666], kh[66666], a[66666], p[66666], fp[66666],
    siz[66666], ck, pa[66666];
vector<int> edge[66666];
int dd[66666];
void dfs(int u) {
  siz[u] = 1;
  p[++ck] = u;
  fp[u] = ck;
  pa[ck] = fp[fa[u]];
  dd[ck] = dd[pa[ck]] + 1;
  for (auto v : edge[u]) {
    dfs(v);
    siz[u] += siz[v];
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", aa + i);
  }
  for (int i = 2; i <= n; ++i) {
    scanf("%d", fa + i);
    edge[fa[i]].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    a[fp[i]] = aa[i];
  }
  for (int i = 1; i <= q; ++i) {
    int x;
    scanf("%d", &x);
    int y = siz[x];
    x = fp[x];
    int pp = i + 1, gg = y >> 3, *jj = kh + x, *diao = dd + x, *aa = a + x;
    int ans = 0, cnt = 0;
    for (int j = 0; j ^ gg; ++j, jj += 8, diao += 8, aa += 8) {
      if (jj[0] < pp) {
        ans += diao[0];
        ++cnt;
        jj[0] = i + aa[0];
      }
      if (jj[1] < pp) {
        ans += diao[1];
        ++cnt;
        jj[1] = i + aa[1];
      }
      if (jj[2] < pp) {
        ans += diao[2];
        ++cnt;
        jj[2] = i + aa[2];
      }
      if (jj[3] < pp) {
        ans += diao[3];
        ++cnt;
        jj[3] = i + aa[3];
      }
      if (jj[4] < pp) {
        ans += diao[4];
        ++cnt;
        jj[4] = i + aa[4];
      }
      if (jj[5] < pp) {
        ans += diao[5];
        ++cnt;
        jj[5] = i + aa[5];
      }
      if (jj[6] < pp) {
        ans += diao[6];
        ++cnt;
        jj[6] = i + aa[6];
      }
      if (jj[7] < pp) {
        ans += diao[7];
        ++cnt;
        jj[7] = i + aa[7];
      }
    }
    gg <<= 3;
    for (int j = gg; j < y; ++j) {
      if (jj[j - gg] < pp) {
        ans += diao[j - gg];
        ++cnt;
        jj[j - gg] = i + aa[j - gg];
      };
    }
    ans = ans - cnt * dd[x];
    printf("%d %d\n", ans, cnt);
  }
}
