#include <bits/stdc++.h>
using namespace std;
long long MOD = (long long)1000000000 + 7;
const long long INF = 1e17;
const long double pi = acos(-1);
const long double EPS = 1e-10;
const long long MAX = 200020;
vector<long long> child[1010];
long long X[1010];
long long N;
long long dp[1010];
bool vis[1010];
long long dp2[1010][5050];
bool ok;
long long func(long long n) {
  if (vis[n]) return dp[1010];
  vis[n] = true;
  long long N = child[n].size();
  if (N == 0) {
    dp[1010] = 0;
    return 0;
  }
  for (long long i = 0; i < 1010; i++) {
    for (long long j = 0; j < 5050; j++) {
      dp2[i][j] = INF;
    }
  }
  dp2[0][0] = 0;
  printf("v:%lld\n", n);
  for (long long i = 0; i < N; i++) {
    long long v = X[child[n][i]], w = func(child[n][i]);
    for (long long j = 0; j < X[n] + 1; j++) {
      dp2[i + 1][j + w] = min(dp2[i + 1][j + w], dp2[i][j] + v);
      dp2[i + 1][j + v] = min(dp2[i + 1][j + v], dp2[i][j] + w);
    }
  }
  printf("v:%lld N:%lld\n", n, N);
  for (long long i = 0; i < N + 1; i++) {
    for (long long j = 0; j < X[n] + 1; j++) {
      printf("%lld %lld:%lld\n", i, j, dp2[i][j]);
    }
  }
  long long res = INF;
  for (long long j = 0; j < X[n] + 1; j++) {
    res = min(res, dp2[N][j]);
  }
  dp[n] = res;
  printf("dp[%lld]:%lld\n", n, res);
  if (res >= INF) ok = false;
  return res;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (long long i = 1; i < N; i++) {
    long long p;
    cin >> p;
    p--;
    child[p].push_back(i);
  }
  for (long long i = 0; i < N; i++) {
    cin >> X[i];
  }
  ok = true;
  long long x = func(0);
  for (long long i = 0; i < N; i++) {
    cout << i << " ";
    cout << dp[i] << '\n';
    ;
  }
  if (ok && x <= X[0]) {
    cout << "POSSIBLE" << '\n';
    ;
  } else {
    cout << "IMPOSSIBLE" << '\n';
    ;
  }
}
