#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LLINF = 1e18;
const double eps = 1e-8;
inline int read1() {
  char ch = getchar();
  int sum = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * f;
}
inline long long read2() {
  char ch = getchar();
  long long sum = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * f;
}
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
};  // namespace fastIO
using namespace fastIO;
const int maxn = 5e4 + 100;
int depth[maxn];
int day[maxn];
int temp[maxn];
vector<int> G[maxn];
int ans1;
int ans2;
int now;
int in[maxn];
int out[maxn];
int d[maxn];
void dfs1(int x) {
  in[x] = now++;
  d[in[x]] = day[x];
  for (int i = 0; i < G[x].size(); i++) {
    depth[now] = depth[in[x]] + 1;
    dfs1(G[x][i]);
  }
  out[x] = now;
}
int main() {
  int N;
  read(N);
  int Q;
  read(Q);
  for (int i = 1; i <= N; i++) {
    read(day[i]);
  }
  for (int i = 2; i <= N; i++) {
    int xx;
    read(xx);
    G[xx].push_back(i);
  }
  dfs1(1);
  for (int i = 0; i < Q; i++) {
    int xx;
    read(xx);
    ans1 = 0;
    ans2 = 0;
    for (int j = in[xx]; j < out[xx]; j++) {
      int take = (temp[j] <= i);
      ans2 += take;
      ans1 += take * (depth[j] - depth[in[xx]]);
      temp[j] = temp[j] * (1 - take) + (i + d[j]) * take;
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}
