#include <bits/stdc++.h>
using namespace std;
struct P {
  int x, y;
  bool operator<(const P &a) const { return y < a.y; };
};
int a, b, c, d, i, k, n, m, e, dx[10] = {1, 0, -1, 0, 1, 1, -1, -1},
                               dy[10] = {0, 1, 0, -1, 1, -1, 1, -1};
int o[1101];
int l[1111];
int j[1];
long long x, y, z, mod = 1000000007;
char r[1];
P u[1];
queue<int> q;
stack<P> s;
vector<int> v[1111];
bool as(P a, P b) { return a.x < b.x; }
void f(int n) {
  int dd[5010], k = 0;
  memset(dd, 0, sizeof(dd));
  dd[0] = 1;
  for (int h = 0; h < v[n].size(); h++) {
    int s[5010];
    memset(s, 0, sizeof(s));
    f(v[n][h]);
    k += l[v[n][h]];
    for (int t = 0; t <= o[n]; t++) {
      if (t >= o[v[n][h]]) s[t] = max(s[t], dd[t - o[v[n][h]]]);
      if (t >= l[v[n][h]] - o[v[n][h]])
        s[t] = max(s[t], dd[t - l[v[n][h]] + o[v[n][h]]]);
    }
    for (int t = 0; t <= o[n]; t++) dd[t] = s[t];
  }
  for (int t = o[n]; t >= 0; t--)
    if (dd[t]) {
      l[n] = k + o[n] - t;
      return;
    }
  puts("IMPOSSIBLE");
  exit(0);
}
int main() {
  scanf("%d", &a);
  for (int t = 2; t <= a; t++) {
    scanf("%d", &n);
    v[n].push_back(t);
  }
  for (int t = 1; t <= a; t++) scanf("%d", &o[t]);
  f(1);
  for (int t = 1; t <= a; t++) printf("%d ", l[t]);
  puts("POSSIBLE");
}
