#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn cost(i: usize, p: &Vec<usize>, x: &Vec<usize>) -> Option<(usize, usize)> {
    let childs: Vec<_> = (0..p.len())
        .filter(|&k| p[k] == i + 1)
        .map(|x| x + 1)
        .collect();
    if childs.is_empty() {
        return Some((x[i], 0));
    }

    let costs: Vec<_> = childs.iter().map(|&c| cost(c, p, x)).collect();
    if costs.iter().any(|c| c.is_none()) {
        None
    } else {
        let costs: Vec<_> = costs.iter().map(|o| o.unwrap()).collect();
        println!("{:?}", costs);
        let total = costs.iter().map(|t| t.0 + t.1).sum::<usize>();

        let mut memo: HashSet<usize> = HashSet::new();
        memo.insert(0);
        for &(a, b) in &costs {
            let mut next = HashSet::new();
            for c in &memo {
                if c + a <= x[i] {
                    next.insert(c + a);
                }

                if c + b <= x[i] {
                    next.insert(c + b);
                }
            }
            memo = next;
        }
        println!("{:?}", memo);

        memo.iter().max().map(|c| (x[i], total - c))
    }

}

fn main() {
    let n: usize = util::get();
    let p: Vec<usize> = util::gets();
    let x: Vec<usize> = util::gets();

    if cost(0, &p, &x).is_some() {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}
