#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <climits>
#include <utility>
#include <iomanip>
#include <cassert>

using namespace std;

using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
template <class T>
using vv = vector<vector<T>>;

#define rep(i, b) for (int i = 0; i < int(b); ++i)
#define reps(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rrep(i, b) for (int i = int(b) - 1; i >= 0; --i)
#define rreps(i, a, b) for (int i = int(b) - 1; i >= a; --i)
#define repe(i, b) for (int i = 0; i <= int(b); ++i)
#define repse(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define rrepe(i, b) for (int i = int(b); i >= 0; --i)
#define rrepse(i, a, b) for (int i = int(b); i >= int(a); --i)

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define mp(a, b) make_pair(a, b)

#define inf (INT_MAX / 2)
#define infl (LONG_MAX / 2)
#define infll (LLONG_MAX / 2)

#define X first
#define Y second
#define pb push_back
#define eb emplace_back

// tools for pair<int, int> & graph
template <class T, size_t M, size_t N>
class graph_delegate_t {
    T (&f)[M][N];

public:
    graph_delegate_t(T (&f)[M][N]) : f(f) {}
    T& operator[](const ii& s) { return f[s.first][s.second]; }
    const T& operator[](const ii& s) const { return f[s.first][s.second]; }
};
ii operator+(const ii& lhs, const ii& rhs) {
    return mp(lhs.first + rhs.first, lhs.second + rhs.second);
}

// clang-format off
template <class T> ostream& operator<<(ostream& os, const vector<T>& t) { os << "{"; rep(i, t.size() - 1) { os << t[i] << ","; } if (!t.empty()) os << t.back(); os << "}"; return os; }
template <class S, class T> ostream& operator<<(ostream& os, const pair<S, T>& t) { return os << "(" << t.first << "," << t.second << ")"; }
vector<string> __macro_split(const string& s) { vector<string> v; int d = 0, f = 0; string t; for (char c : s) { if (!d && c == ',') v.pb(t), t = ""; else t += c; if (c == '\"' || c == '\'') f ^= 1; if (!f && c == '(') ++d; if (!f && c == ')') --d; } v.pb(t); return v; }
void __args_output(vector<string>::iterator, vector<string>::iterator) { cerr << endl; }
template <typename T, typename... Args>
void __args_output(vector<string>::iterator it, vector<string>::iterator end, T a, Args... args) { cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a; if (++it != end) { cerr << ", "; } __args_output(it, end, args...); }
#define out(args...) { vector<string> __args = __macro_split(#args); __args_output(__args.begin(), __args.end(), args); }
// clang-format on

const int MAX_N = 1000 + 5;
const int MAX_X = 5000;

int par[MAX_N];
int X[MAX_N], Y[MAX_N];
vector<int> childs[MAX_N];

bool dp[MAX_N][MAX_X + 1];

bool dfs(int s) {
    if (childs[s].empty()) {
        return true;
    }

    for (auto t : childs[s]) {
        if (!dfs(t)) {
            return false;
        }
    }

    auto t = childs[s].front();
    if (X[t] <= X[s]) dp[t][X[t]] = true;
    if (Y[t] <= X[s]) dp[t][Y[t]] = true;
    auto prev = t;
    for (int i = 1; i < sz(childs[s]); ++i) {
        t = childs[s][i];
        for (int j = 0; j <= X[s]; ++j) {
            if (j - X[t] >= 0) dp[t][j] |= dp[prev][j - X[t]];
            if (j - Y[t] >= 0) dp[t][j] |= dp[prev][j - Y[t]];
        }
        prev = t;
    }

    int sum = 0;
    for (auto t : childs[s]) {
        sum += X[t] + Y[t];
    }
    Y[s] = -1;
    for (int i = X[s]; i >= 0; --i) {
        if (dp[t][i]) {
            Y[s] = sum - i;
            break;
        }
    }

    if (Y[s] == -1) return false;
    out(s, X[s], Y[s]);

    return true;
}

int main() {
    int n;
    cin >> n;
    par[1] = 1;
    repse(i, 2, n) cin >> par[i];
    repse(i, 1, n) cin >> X[i];
    repse(i, 2, n) { childs[par[i]].push_back(i); }

    if (!dfs(1))
        cout << "IMPOSSIBLE" << endl;
    else
        cout << "POSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 5120