#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
const int N = 5e4 + 5;
int n, q;
int a[N], b[N];
int depth[N], in[N], out[N], p[N], tmp[N];
vector<int> g[N];
int nodes = 0;
int x[N];
void dfs(int v) {
  in[v] = nodes++;
  for (int u : g[v]) {
    depth[u] = depth[v] + 1;
    dfs(u);
  }
  out[v] = nodes;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 1; i < n; ++i) {
    scanf("%d", p + i);
    --p[i];
    g[p[i]].push_back(i);
  }
  depth[0] = 0;
  dfs(0);
  for (int i = 0; i < n; ++i) {
    b[in[i]] = a[i];
    a[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    tmp[in[i]] = depth[i];
  }
  for (int i = 0; i < n; ++i) depth[i] = tmp[i];
  for (int i = 0; i < q; ++i) {
    int v;
    scanf("%d", &v);
    --v;
    int sum = 0, cnt = 0;
    int from = in[v], til = out[v];
    for (int j = from; j < til; ++j) {
      if (a[j] <= i) {
        sum += depth[j];
        a[j] = i + b[j];
        ++cnt;
      }
    }
    printf("%d %d\n", sum - depth[in[v]] * cnt, cnt);
  }
  return 0;
}
