#include <bits/stdc++.h>
using namespace std;
template <typename __T>
inline void read(__T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
int fa[1005];
int val[1005];
int n;
int v[1005];
int dp[1005][5005];
int tmp[5005];
vector<int> son[1005];
void dfs(int now) {
  dp[now][0] = 0;
  for (int i = 0; i < son[now].size(); i++) {
    dfs(son[now][i]);
    for (int i = 0; i <= val[now]; i++) tmp[i] = dp[now][i];
    memset(dp[now], 23, sizeof(dp[now]));
    for (int j = val[now]; j >= 0; j--) {
      if (j >= val[son[now][i]])
        dp[now][j] = min(dp[now][j], tmp[j - val[son[now][i]]] +
                                         dp[son[now][i]][val[son[now][i]]]);
      if (j >= dp[son[now][i]][val[son[now][i]]])
        dp[now][j] =
            min(dp[now][j],
                tmp[j - dp[son[now][i]][val[son[now][i]]]] + val[son[now][i]]);
    }
  }
  for (int i = 1; i <= val[now]; i++)
    dp[now][i] = min(dp[now][i - 1], dp[now][i]);
}
int main() {
  read(n);
  memset(dp, 23, sizeof(dp));
  for (int i = 2; i <= n; i++) {
    read(fa[i]);
    son[fa[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) read(val[i]);
  dfs(1);
  cout << dp[1][val[1]] << endl;
  if (dp[1][val[1]] <= 123456)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}
