#include <bits/stdc++.h>
const int MAXN = 1000;
int get_int() {
  int x = 0, y = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') y = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
int dp[MAXN], f[MAXN], v[MAXN], n;
class Edge {
 public:
  int next, to;
} edges[MAXN << 1];
int edgesNum, head[MAXN];
void addEdge(int from, int to) {
  edges[edgesNum] = (Edge){head[from], to};
  head[from] = edgesNum++;
}
void getAns(int now) {
  for (int i = head[now]; i != -1; i = edges[i].next) {
    int to = edges[i].to;
    getAns(to);
  }
  dp[0] = 0;
  for (int i = head[now]; i != -1; i = edges[i].next) {
    for (int j = v[now]; j >= 0; j--) {
      int to = edges[i].to, temp = 0x3f3f3f3f;
      temp = std ::min(j >= f[to] ? dp[j - f[to]] + v[to] : 0x3f3f3f3f, temp);
      temp = std ::min(j >= v[to] ? dp[j - v[to]] + f[to] : 0x3f3f3f3f, temp);
      dp[j] = temp;
    }
  }
  int min = 0x3f3f3f3f;
  for (int i = 0; i <= v[now]; i++) min = std ::min(min, dp[i]);
  if (min >= 0x3f3f3f3f) {
    std::cout << "IMPOSSIBLE";
    exit(0);
  }
  f[now] = min;
}
int main() {
  memset(head, -1, sizeof(head));
  memset(f, 0x3f, sizeof(f));
  n = get_int();
  for (int i = 1; i < n; i++) addEdge(get_int() - 1, i);
  for (int i = 0; i < n; i++) v[i] = get_int();
  getAns(0);
  for (int i = 0; i < n; i++) std ::cout << f[i] << ' ';
  std ::cout << std ::endl;
  std::cout << "POSSIBLE";
  return 0;
}
