#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
vvi g;
int v[1010];
int dp[1010];
bitset<5050> bs[2];
bool pos;
int ds(int u) {
	if(dp[u] != -1) return dp[u];
	for(int i=0;i<g[u].size();i++) {
		ds(g[u][i]);
	}
	bs[0].reset();bs[1].reset();
	bs[0].set(0);
	int cu = 1;
	int tot = 0;
	for(int i=0;i<g[u].size();i++) {
		bs[cu].reset();
		int a = ds(g[u][i]),b = v[g[u][i]];
		tot += a+b;
		for(int j=0;j<=v[u];j++) {
			if((j-a >= 0) && bs[1-cu][j-a]) {bs[cu].set(j);}
			if((j-b >= 0) && bs[1-cu][j-b]) {bs[cu].set(j);}
		}
		cu = 1-cu;
	}
	cu = 1-cu;
	int mi = -1;
	for(int i=v[u];i>=0;i--) {
		if(bs[cu][i]) {mi = i;break;}
	}
	if(mi == -1) {pos = false;return dp[u] = 9999;}
	return dp[u] = tot-mi;
}
int main() {
	int n;
	scanf("%d ",&n);
	g.assign(n,vi());
	memset(dp,-1,sizeof(dp));
	pos = true;
	for(int i=1;i<n;i++) {
		int t;
		scanf("%d ",&t);t--;
		g[t].push_back(i);
	}
	for(int i=0;i<n;i++) {
		scanf("%d ",&v[i]);
	}
	ds(0);
	printf("%sPOSSIBLE\n",pos?"":"IM");
}
