#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
template <typename A, typename B>
inline void Max(A &x, B y) {
  if (x < y) x = y;
}
template <typename A, typename B>
inline void Min(A &x, B y) {
  if (x > y) x = y;
}
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <typename A>
inline bool read(A &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
  return 1;
}
inline bool read(char &x) {
  while ((x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                           (iS == iT ? EOF : *iS++))
                        : *iS++)) == ' ' ||
         x == '\n' || x == '\r')
    ;
  return x != EOF;
}
inline bool read(char *x) {
  while ((*x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                            (iS == iT ? EOF : *iS++))
                         : *iS++)) == '\n' ||
         *x == ' ' || *x == '\r')
    ;
  if (*x == EOF) return 0;
  while (!(*x == '\n' || *x == ' ' || *x == '\r' || *x == EOF))
    *(++x) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                          (iS == iT ? EOF : *iS++))
                       : *iS++);
  *x = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &x, B &...y) {
  return read(x) && read(y...);
}
template <typename A>
inline bool write(A x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
  return 0;
}
inline bool write(char x) {
  putc(x);
  return 0;
}
inline bool write(const char *x) {
  while (*x) {
    putc(*x);
    ++x;
  }
  return 0;
}
inline bool write(char *x) {
  while (*x) {
    putc(*x);
    ++x;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A x, B... y) {
  return write(x) || write(y...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
namespace IO2 {
template <class T>
inline bool read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + (c ^ 48);
  x *= f;
  return c != EOF;
}
inline bool read(char &x) {
  while ((x = getchar()) == ' ' || x == '\n' || x == '\r')
    ;
  return x != EOF;
}
inline bool read(char *x) {
  while ((*x = getchar()) == '\n' || *x == ' ' || *x == '\r')
    ;
  if (*x == EOF) return 0;
  while (!(*x == '\n' || *x == ' ' || *x == '\r' || *x == EOF))
    *(++x) = getchar();
  *x = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &x, B &...y) {
  return read(x) && read(y...);
}
template <typename A>
inline bool write(A x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return 0;
}
inline bool write(char x) {
  putchar(x);
  return 0;
}
inline bool write(const char *x) {
  while (*x) {
    putchar(*x);
    ++x;
  }
  return 0;
}
inline bool write(char *x) {
  while (*x) {
    putchar(*x);
    ++x;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A x, B... y) {
  return write(x) || write(y...);
}
};  // namespace IO2
const int mod = 1e9 + 7;
const int maxm = 5e4 + 80;
const int NN = 21;
vector<int> e[maxm];
int dep[maxm], a[maxm], take[maxm];
int in[maxm], out[maxm], b[maxm], ti;
void dfs(int u) {
  in[u] = ++ti;
  b[ti] = a[u];
  for (int v : e[u]) dfs(v);
  out[u] = ti;
}
void D(int u) {
  for (int v : e[u]) dep[in[v]] = dep[in[u]] + 1, D(v);
}
int main() {
  int n, Q;
  read(n, Q);
  for (int i = 1; i <= n; i++) read(a[i]), take[i] = -2 * maxm;
  for (int v = 2; v <= n; v++) {
    int u;
    read(u);
    e[u].push_back(v);
  }
  dfs(1);
  D(1);
  for (register int day = 1; day <= Q; day++) {
    int tu;
    read(tu);
    const int u = tu;
    int d = 0, s = 0;
    const int st = in[u], en = out[u], iu = in[u];
    for (register int i = st; i <= en; i++) {
      bool opt = take[i] + b[i] <= day;
      s += opt;
      d += opt * (dep[i] - dep[iu]);
      take[i] = opt ? day : take[i];
    }
    write(d, ' ', s, '\n');
  }
  return 0;
}
