Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.

Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree with colored vertices.

Now Appleman wonders, what is the number of sets splitting the tree in such a way that each resulting part will have exactly one black vertex? Find this number modulo 1000000007 (109 + 7).

Input

The first line contains an integer n (2 ≤ n ≤ 105) — the number of tree vertices. 

The second line contains the description of the tree: n - 1 integers p0, p1, ..., pn - 2 (0 ≤ pi ≤ i). Where pi means that there is an edge connecting vertex (i + 1) of the tree and vertex pi. Consider tree vertices are numbered from 0 to n - 1.

The third line contains the description of the colors of the vertices: n integers x0, x1, ..., xn - 1 (xi is either 0 or 1). If xi is equal to 1, vertex i is colored black. Otherwise, vertex i is colored white.

Output

Output a single integer — the number of ways to split the tree modulo 1000000007 (109 + 7).

Examples

Input

3
0 0
0 1 1


Output

2


Input

6
0 1 1 0 4
1 1 0 0 1 0


Output

1


Input

10
0 1 2 1 4 4 4 0 8
0 0 0 1 0 1 1 0 0 1


Output

27
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author karan173
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB
{
    int n;
    ArrayList<Integer> G[];
    boolean color[];
    long mod = (long) (1e9 + 7);
    long dp[][]; //dp[0] without , dp[1] - with
    public void solve(int testNumber, FastReader in, PrintWriter out)
    {
        n = in.ni ();
        G = new ArrayList[n];
        dp = new long[n][2];
        color = new boolean[n];
        for (int i = 0; i < n; i++)
        {
            G[i] = new ArrayList<Integer> ();
        }
        for (int i = 0; i < n - 1; i++)
        {
            int x = in.ni ();
            G[x].add (i + 1);
            G[i + 1].add (x);
        }
        for (int i = 0; i < n; i++)
        {
            color[i] = in.ni () == 1;
        }
        dfs (0, -1);
        out.println (dp[0][1]);
    }

    private void dfs(int i, int par)
    {
        int xx = G[i].size () - (par == -1 ? 0 : 1);
        if (xx == 0)
        {
            if (color[i])
            {
                dp[i][0] = 0;
                dp[i][1] = 1;
            }
            else
            {
                dp[i][0] = 1;
                dp[i][1] = 0;
            }
            return;
        }
        if (color[i])        //black
        {
            dp[i][0] = 0; //without
            dp[i][1] = 1;
            for (int v : G[i])
            {
                if (v == par)
                {
                    continue;
                }
                dfs (v, i);
                //two cases, cut edge, but then v must be with
                //dont cut edge, v must be without
                long sum = dp[v][0] + dp[v][1];
                sum %= mod;
                dp[i][1] *= sum;
                dp[i][1] %= mod;
            }
        }
        else     //white
        {
            //for with case, it must be linked to one of its children which is with
            //choose 1 child, take its with
            //for rest 2 cases -> cut edge -> take with
            //dont cut edge -> take without
            //hence take sums of rest

            //for without case
            //case 1 cut edge -> take with
            //case 2 dont cut edge -> take without
            int n = G[i].size ();
            for (int v : G[i])
            {
                if (v == par)
                {
                    continue;
                }
                dfs (v, i);
            }
            long lProduct[] = new long[n + 1];
            long rProduct[] = new long[n + 1];
            lProduct[0] = 1;
            for (int j = 1; j <= n; j++)
            {
                int v = G[i].get (j - 1);
                lProduct[j] = lProduct[j - 1];
                if (v == par)
                {
                    continue;
                }
                long sum = dp[v][0] + dp[v][1];
                sum %= mod;
                lProduct[j] *= (sum);
                lProduct[j] %= mod;
            }
            rProduct[n] = 1;
            for (int j = n - 1; j >= 0; j--)
            {
                rProduct[j] = rProduct[j + 1];
                int v = G[i].get (j);
                if (v == par)
                {
                    continue;
                }
                long sum = dp[v][0] + dp[v][1];
                sum %= mod;
                rProduct[j] *= (sum);
                rProduct[j] %= mod;
            }
            dp[i][1] = 0;
            for (int j = 0; j < n; j++)
            {
                int v = G[i].get (j);
                if (v == par)
                {
                    continue;
                }
                long ways = dp[v][1];
                ways *= lProduct[j];
                ways %= mod;
                ways *= rProduct[j + 1];
                ways %= mod;
                dp[i][1] += ways;
                dp[i][1] %= mod;
            }
            dp[i][0] = rProduct[0];
        }
    }
}

class FastReader
{

    public InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastReader(InputStream stream)
    {
        this.stream = stream;
    }

    public FastReader()
    {

    }

    public int read()
    {
        if (numChars == -1)
        {
            throw new InputMismatchException ();
        }
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read (buf);
            } catch (IOException e)
            {
                throw new InputMismatchException ();
            }
            if (numChars <= 0)
            {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int ni()
    {
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read ();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
            {
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
        {
            return filter.isSpaceChar (c);
        }
        return isWhitespace (c);
    }

    public static boolean isWhitespace(int c)
    {
        return c==' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}
