#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long power(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return (res % mod);
}
long long t, tt, n, i, j, k, x, y, l, r, ans;
long long a[100005];
vector<long long> v[100005];
vector<long long> vv[100005];
long long sum[100005];
long long cnt[100005];
long long on[100005];
long long q;
void dfs(long long node, long long level) {
  for (long long i = 0; i < vv[node].size(); i++) {
    on[vv[node][i]] = level;
  }
  for (i = 1; i <= q; i++) {
    if (on[i]) {
      cnt[i]++;
      sum[i] += level - on[i];
      i += a[node] - 1;
    }
  }
  for (long long ii = 0; ii < v[node].size(); ii++) {
    dfs(v[node][ii], level + 1);
  }
  for (i = 0; i < vv[node].size(); i++) on[vv[node][i]] = 0;
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  tt = 1;
  while (tt--) {
    cin >> n >> q;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = 2; i <= n; i++) {
      cin >> x;
      v[x].push_back(i);
    }
    for (i = 1; i <= q; i++) {
      cin >> x;
      vv[x].push_back(i);
    }
    dfs(1, 1);
    for (i = 1; i <= q; i++) cout << sum[i] << " " << cnt[i] << '\n';
  }
}
