#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
using namespace std;
const long long oo = (long long)(1e9);
int a[(long long)(1e5 + 5)];
int t[(long long)(1e5 + 5)];
vector<int> g[(long long)(1e5 + 5)];
int lvl[(long long)(1e5 + 5)];
bool mk[(long long)(1e5 + 5)];
int li[(long long)(1e5 + 5)], ls[(long long)(1e5 + 5)];
int ip[(long long)(1e5 + 5)];
int cont;
int px[(long long)(1e5 + 5)];
int aa[(long long)(1e5 + 5)];
int lvll[(long long)(1e5 + 5)];
void dfs(int u) {
  mk[u] = 1;
  li[u] = cont;
  ip[cont] = u;
  px[cont] = u;
  cont++;
  for (auto v : g[u])
    if (!mk[v]) {
      lvl[v] = lvl[u] + 1;
      dfs(v);
    }
  ls[u] = cont - 1;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    g[p].push_back(i);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    aa[i] = a[ip[i]];
    lvll[i] = lvl[ip[i]];
  }
  for (int i = 0; i < q; i++) {
    int r1 = 0;
    int r2 = 0;
    int u;
    cin >> u;
    u--;
    for (int j = li[u]; j <= ls[u]; j++)
      if (t[j] <= i) {
        r1++;
        r2 += lvll[j];
        t[j] = i + aa[j];
      }
    r2 -= r1 * lvl[u];
    cout << r2 << ' ' << r1 << '\n';
  }
  return 0;
}
