#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

struct Node {
    int parent;
    std::vector<int> children;
    std::pair<int, int> bw_value;
    int rank;
};

const int MAX_N = 1050;
const int MAX_VALUE = 5050;
bool dp[MAX_N][MAX_VALUE] = {};
int N;
int P[MAX_N], X[MAX_N];

Node node[MAX_N];
std::vector<std::pair<int, int>> rank_node;

std::pair<int, int> dp_choice(const int node_value, std::vector<std::pair<int, int>> child_value) {
    int sum = 0;
    for (std::pair<int, int> child : child_value) {
        sum += child.first + child.second;
    }

    for (int i = 0; i <= child_value.size(); i++) {
        for (int val = 0; val <= node_value; val++) {
            dp[i][val] = false;
        }
    }

    dp[0][0] = true;

    for (int i = 0; i < child_value.size(); i++) {
        for (int val = 0; val <= node_value; val++) {
            if (dp[i][val]) {
                if (val + child_value[i].first <= node_value) {
                    dp[i+1][val + child_value[i].first] = true;
                }
                if (val + child_value[i].second <= node_value) {
                    dp[i+1][val + child_value[i].second] = true;
                }
            }
        }
    }

    std::pair<int, int> ret;
    ret.first = -1;
    ret.second = -1;
    for (int val = 0; val <= node_value; val++) {
        if (dp[child_value.size()][val]) {
            ret.first = val;
            ret.second = sum - val;
        }
    }
    if (ret.first != -1) {
        ret.first = node_value;
    }
    return ret;
}

void set_child_rank(int i, int current_rank) {
    for (int child : node[i].children) {
        node[child].rank = current_rank + 1;
        set_child_rank(child, node[child].rank);
    }
}

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 2; i <= N; i++) {
        std::cin >> P[i];
    }

    for (int i = 1; i <= N; i++) {
        std::cin >> X[i];
    }

    for (int i = 2; i <= N; i++) {
        node[i].parent = P[i];
        node[P[i]].children.push_back(i);
    }

    node[1].rank = 0;
    set_child_rank(1, node[1].rank);

    for (int i = 1; i <= N; i++) {
        rank_node.push_back(std::pair<int, int>({node[i].rank, i}));
    }

    std::sort(rank_node.begin(), rank_node.end(),
        [](const std::pair<int, int>& x, const std::pair<int, int>& y) { return x.first > y.first; }
    );

    for (std::pair<int, int> pair : rank_node) {
        int i = pair.second;
        std::vector<std::pair<int, int>> child_value;
        for (int child : node[i].children) {
            child_value.push_back(node[child].bw_value);
        }
        node[i].bw_value = dp_choice(X[i], child_value);
        if (node[i].bw_value.first == -1) {
            std::cout << "IMPOSSIBLE" << std::endl;
            return 0;
        }
    }

    std::cout << "POSSIBLE" << std::endl;
    return 0;

}

Measured memory_bytes: 4736