#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;
int speed[50005], pre[50005], post[50005], depth[50005], last_harv[50005],
    rev_map[50005];
vector<int> adj[50005];
int mycount;
void go(int on) {
  pre[on] = mycount++;
  for (int nex : adj[on]) {
    depth[nex] = depth[on] + 1;
    go(nex);
  }
  post[on] = mycount - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> speed[i];
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    adj[p - 1].push_back(i);
  }
  mycount = 0;
  depth[0] = 0;
  go(0);
  for (int i = 0; i < n; i++) {
    rev_map[pre[i]] = i;
    last_harv[i] = -1000000;
  }
  for (int i = 0; i < q; i++) {
    int x;
    cin >> x;
    x--;
    int num = 0;
    int sum = 0;
    for (int j = pre[x]; j <= post[x]; j++) {
      if (i - last_harv[j] >= speed[rev_map[j]]) {
        last_harv[j] = i;
        num++;
        sum += depth[rev_map[j]];
      }
    }
    cout << (sum - num * depth[x]) << " " << num << endl;
  }
  return 0;
}
