#include<bits/stdc++.h>
#define inf ((int)0x3f3f3f3f)
#define neinf ((int)0xc1c1c1c1)
#define llinf ((ll)0x3f3f3f3f3f3f3f3f)
#define nellinf ((ll)0xc1c1c1c1c1c1c1c1)
#define ull unsigned long long
#define uint usigned int
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define eps 1e-6
#define PB push_back
#define PI acos(-1)
#define lmove(n) (1<<(n))
#define FI first
#define SE second
#define Ceil(x,y) ((x+y-1)/y)
using namespace std;
typedef pair<int,int> Pair;
const int MAXN=5e3+100;
const int mod=1e9+7;
int n;
vector<int>G[MAXN];
int val[MAXN];
bool flag;
int color[MAXN][2];
int op[MAXN][2];
void dfs(int u,int pa) {
    if(!flag) return ;
    for(auto v:G[u]) {
        if(v==pa) continue;
        dfs(v,u);
    }
    if(!flag) return ;
    for(int i=0; i<2; i++) {
        int sum=0;
        int opsum=0;
        vector<int>tmp;
        for(auto v:G[u]) {
            if(v==pa) continue;
            if(color[v][i]==1&&color[v][i^1]==0) {
                sum+=val[v];
                opsum+=op[v][i^1];
            } else if(color[v][i]==1&&color[v][i^1]==1) {
                tmp.PB(v);
            } else if(color[v][i]==0&&color[v][i^1]==1) {
                sum+=op[v][i];
                opsum+=val[v];
            }
        }
        if(sum>val[u]) {
            color[u][i]=0;
        }
        else {
            color[u][i]=1;
            int len=val[u]-sum;
            unordered_map<int,int>dp;
            dp[0]=0;
            for(auto v:tmp) {
                unordered_map<int,int>other;
                for(auto elem:dp){
                    int x=elem.FI,y=elem.SE;
                    if(x+val[v]<=len){
                        int ttt=x+val[v];
                        if(!other.count(ttt)) other[ttt]=y+op[v][i^1];
                        else if(other[ttt]>y+op[v][i^1]) other[ttt]=y+op[v][i^1];
                    }
                    if(x+op[v][i]<=len){
                        int ttt=x+op[v][i];
                        if(!other.count(ttt)) other[ttt]=y+val[v];
                        else if(other[ttt]>y+val[v]) other[ttt]=y+val[v];
                    }
                }
                swap(dp,other);
            }
            int ans=inf;
            for(auto elem:dp){
                ans=min(ans,elem.SE);
            }
            if(ans==inf&&G[u].size()==1&&u!=1) {
                op[u][i^1]=opsum;
            }
            else if(ans==inf){
                color[u][i]=0;
            }
            else op[u][i^1]=opsum+ans;
        }
    }
    if(color[u][0]==0&&color[u][1]==0) flag=0;
}
int main() {
#ifndef ONLINE_JUDGE
    //FREI;
#endif // ONLINE_JUDGE
    scanf("%d",&n);
    flag=1;
    Mem(color,-1);
    for(int i=2; i<=n; i++) {
        int v;
        scanf("%d",&v);
        G[i].PB(v);
        G[v].PB(i);
    }
    for(int i=1; i<=n; i++) scanf("%d",&val[i]);
    dfs(1,1);
//    for(int i=1;i<=n;i++){
//        cout<<color[i][0]<<' '<<op[i][1]<<' '<<color[i][1]<<' '<<op[i][0]<<endl;
//    }
    flag?puts("POSSIBLE"):puts("IMPOSSIBLE");
}



Measured memory_bytes: 648