#include <bits/stdc++.h>
using namespace std;
vector<long long int> P(1001, 0), c(1001, 0), x(1001);
vector<vector<long long int> > G =
    vector<vector<long long int> >(1001, vector<long long int>(0, 0));
vector<vector<long long int> > num =
    vector<vector<long long int> >(1001, vector<long long int>(2, -1));
deque<long long int> w;
void dfs(long long int now) {
  std::cout << now << '\n';
  if (num[now][0] != -1) return;
  if (G[now].size() == 0)
    num[now][0] = x[now], num[now][1] = 0;
  else {
    long long int f = 0, s = 0;
    for (int i = 0; i < G[now].size(); i++)
      f += num[G[now][i]][0], s += num[G[now][i]][1];
    if (x[now] < s) {
      std::cout << "IMPOSSIBLE" << '\n';
      exit(0);
    }
    vector<vector<bool> > dp =
        vector<vector<bool> >(G[now].size() + 1, vector<bool>(5001, false));
    dp[0][0] = true;
    for (int i = 1; i <= G[now].size(); i++) {
      for (int j = 0; j <= 5000; j++) {
        dp[i][j] = (dp[i][j] || dp[i - 1][j]);
        if (j + num[G[now][i - 1]][0] <= 5000) {
          dp[i][j + num[G[now][i - 1]][0]] =
              (dp[i][j + num[G[now][i - 1]][0]] || dp[i - 1][j]);
        }
        if (j + num[G[now][i - 1]][1] <= 5000) {
          dp[i][j + num[G[now][i - 1]][1]] =
              dp[i][j + num[G[now][i - 1]][1]] || dp[i - 1][j];
        }
      }
    }
    int k;
    for (k = x[now]; k >= 0; k--)
      if (dp[G[now].size()][k]) break;
    num[now][0] = max(x[now], f + s - k), num[now][1] = min(x[now], f + s - k);
  }
  c[P[now]]++;
  if (c[P[now]] == G[P[now]].size()) w.push_back(P[now]);
}
int main(int argc, char const *argv[]) {
  long long int N, a;
  std::cin >> N;
  for (int i = 2; i <= N; i++) {
    std::cin >> a;
    P[i] = a;
    G[a].push_back(i);
  }
  for (int i = 1; i <= N; i++) std::cin >> x[i];
  for (int i = 1; i <= N; i++)
    if (G[i].size() == 0) w.push_back(i);
  while (!w.empty()) {
    long long int W = w.front();
    w.pop_front();
    dfs(W);
  }
  std::cout << "POSSIBLE" << '\n';
  return 0;
}
