#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 5e4 + 8;
vector<int> g[N];
int a[N], dep[N], tin[N], tout[N], b[N], act[N];
int timer = 0;
void dfs(int s, int prv = -1) {
  tin[s] = ++timer;
  b[timer] = a[s];
  if (prv == -1)
    dep[tin[s]] = 0;
  else
    dep[tin[s]] = dep[tin[prv]] + 1;
  for (auto u : g[s]) dfs(u, s);
  tout[s] = timer;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  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 t = 1; t <= q; t++) {
    int x;
    cin >> x;
    x--;
    int sum = 0, cnt = 0;
    for (int i = tin[x]; i <= tout[x]; i++) {
      if (act[i] <= t) {
        sum += dep[i] - dep[tin[x]];
        cnt++;
        act[i] = t + b[i];
      }
    }
    cout << sum << " " << cnt << '\n';
  }
}
