#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 5e4 + 10;
vector<pair<long long, long long> > allchilds[N];
long long times[N], growthspeeds[N], parents[N];
long long n, q, tot = 0, ans = 0, x, cost = 0, node;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  long long a;
  for (long long i = 1; i <= n; ++i) cin >> growthspeeds[i];
  for (long long i = 2; i <= n; ++i) {
    cin >> a;
    parents[i] = a;
  }
  for (long long i = 1; i <= n; ++i) {
    long long curr = i;
    cost = 0;
    while (true) {
      allchilds[curr].push_back({i, cost});
      if (curr == 1) break;
      curr = parents[curr];
      cost++;
    }
  }
  memset(times, 0, sizeof(times));
  for (long long day = 1; day <= q; ++day) {
    cin >> x;
    ans = tot = 0;
    for (pair<long long, long long> childs : allchilds[x]) {
      node = childs.first;
      cost = childs.second;
      if (times[node] <= day) {
        ans += cost;
        tot += 1;
        times[node] = day + growthspeeds[node];
      }
    }
    cout << ans << " " << tot << "\n";
  }
}
