#include <bits/stdc++.h>
const int maxN = 5010, oo = 23041997;
using namespace std;
int f[maxN], x[maxN], g[maxN], n;
vector<int> adj[maxN];
void dp(int u) {
  for (int i = 0; i <= x[u]; ++i) g[i] = oo;
  f[u] = oo;
  g[0] = 0;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    dp(v);
    if (f[v] == oo) return;
    for (int j = x[u]; j >= 0; --j) {
      int tmp = oo;
      if (j >= f[v]) tmp = min(tmp, g[j - f[v]] + x[v]);
      if (j >= x[v]) tmp = min(tmp, g[j - x[v]] + f[v]);
      g[j] = tmp;
    }
  }
  for (int i = 0; i <= x[u]; ++i) f[u] = min(f[u], g[i]);
  cout << u << " " << f[u] << endl;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    int p;
    scanf("%d", &p);
    adj[p].push_back(i + 1);
  }
  for (int i = 1; i <= n; ++i) cin >> x[i];
  dp(1);
  if (f[1] != oo)
    cout << "POSSIBLE";
  else
    cout << "IMPOSSIBLE";
}
