#include <bits/stdc++.h>
using namespace std;
long long Lis(long long *data, long long *dp, long long n) {
  fill(dp, dp + n, (1ll << 60));
  for (long long i = 0; i < (n); ++i) {
    *lower_bound(dp, dp + n, data[i]) = data[i];
  }
  return lower_bound(dp, dp + n, (1ll << 60)) - dp;
}
long long N;
vector<long long> ch[1010];
long long X[1010];
vector<long long> sequence;
long long lisdp[1010];
bool can = true;
void dfs(long long cur, long long prevlis) {
  if (prevlis == 2) {
    if (lisdp[0] < X[cur] && X[cur] < lisdp[1]) {
      can = false;
      return;
    }
  }
  sequence.push_back(X[cur]);
  long long lis = Lis(sequence.data(), lisdp, sequence.size());
  if (lis == prevlis) {
    sequence.pop_back();
    Lis(sequence.data(), lisdp, sequence.size());
    sequence.push_back(X[cur]);
  }
  if (lis >= 3) {
    can = false;
    return;
  }
  for (long long i = 0; i < (ch[cur].size()); ++i) {
    dfs(ch[cur][i], lis);
    if (can == false) return;
    if (lis == prevlis) {
      sequence.pop_back();
      Lis(sequence.data(), lisdp, sequence.size());
      sequence.push_back(X[cur]);
    }
  }
  sequence.pop_back();
}
signed main() {
  cin >> N;
  for (long long i = 0; i < (N - 1); ++i) {
    long long p;
    cin >> p;
    --p;
    ch[p].push_back(i + 1);
  }
  for (long long i = 0; i < (N); ++i) {
    cin >> X[i];
  }
  dfs(0, 0);
  if (can) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}
