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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class CodeB {
  static final long MOD = 1000000007L;

  static long[] gcd(long p, long q)
  {
      if (q == 0)
          return new long[] { p, 1, 0 };
      long[] vals = gcd(q, p % q);
      long d = vals[0];
      long a = vals[2];
      long b = vals[1] - (p / q) * vals[2];
      return new long[] { d, a, b };
  }

  static long inverse(long k, long n) 
  {
      long[] vals = gcd(k, n);
      long d = vals[0];
      long a = vals[1];
      if (d > 1) { return 0; }
      if (a > 0) return a;
      return n + a;
  }

  static class Node {
    ArrayList<Node> sons = new ArrayList<Node>();
    boolean black;
    long[] dp = Scanner.fill(new long[2], -1);

    public Node() {
    }

    long dp(int count) {
      if (dp[count + 1] != -1) {
        return dp[count + 1];
      }
      if (sons.size() == 0) {
        if (black) {
          if (count == -1) {
            return dp[count + 1] = 1L;
          } else {
            return dp[count + 1] = 0L;
          }
        } else {
          return dp[count + 1] = count == 0 ? 1L : 0L;
        }
      }
      if (black) {
        if (count == 0) {
          return dp[count + 1] = 0L;
        }
        long answer = 1;
        for (Node n : sons) {
          answer *= (n.dp(-1) + n.dp(0)) % MOD;
          answer %= MOD;
        }
        return dp[count + 1] = answer;
      } else {
        if (count == 0) {
          long answer = 1;
          for (Node n : sons) {
            answer *= (n.dp(-1) + n.dp(0)) % MOD;
            answer %= MOD;
          }
          return dp[count + 1] = answer;
        } else {
          long answer = 0;
          long answerZero = 1;
          for (Node n : sons) {
            answerZero *= (n.dp(-1) + n.dp(0)) % MOD;
            answerZero %= MOD;
          }
          for (Node n : sons) {
            answer += (n.dp(-1) * ((answerZero * inverse(n.dp(-1) + n.dp(0), MOD)) % MOD)) % MOD;
            answer %= MOD;
          }
          return dp[count + 1] = answer;
        }
      }      
    }
  }

  public static void main(String[] args) {
    Scanner sc = new SuperScanner();
    int n = sc.nextInt();
    Node[] nodes = sc.nextObjectArray(Node.class, n);
    for (int i = 1; i < n; i++) {
      nodes[sc.nextInt()].sons.add(nodes[i]);
    }
    for (int i = 0; i < n; i++) {
      nodes[i].black = sc.nextInt() == 1;
    }
    System.out.println(nodes[0].dp(-1));
  }

  static class SuperScanner extends Scanner {
    private InputStream stream;
    private byte[] buf = new byte[8096];
    private int curChar;
    private int numChars;

    public SuperScanner() {
        this.stream = System.in;
    }

    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 static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
    
    private final StringBuilder sb = new StringBuilder();
    
    @Override
    public String next() {
      int c = read();
      while (isWhitespace(c)) {
          if (c == -1) {
            return null;
          }
          c = read();
      }
      sb.setLength(0);
      do {
          sb.append((char) c);
          c = read();
      } while (!isWhitespace(c));
      return sb.toString();
    }

    @Override
    public int nextInt() {
        int c = read();
        while (isWhitespace(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 = (res << 3) + (res << 1);
            res += c - '0';
            c = read();
        } while (!isWhitespace(c));
        return res * sgn;
    }

    @Override
    public long nextLong() {
        int c = read();
        while (isWhitespace(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res = (res << 3) + (res << 1);
            res += c - '0';
            c = read();
        } while (!isWhitespace(c));
        return res * sgn;
    }
  }
  
  static class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");

    public String nextLine() {
      try {
        return br.readLine();
      } catch (Exception e) {
        throw (new RuntimeException());
      }
    }

    public int nextIntOrQuit() {
      Integer n = nextInteger();
      if (n == null) {
        System.exit(0);
      }
      return n.intValue();
    }

    public String next() {
      while (!st.hasMoreTokens()) {
        String l = nextLine();
        if (l == null)
          return null;
        st = new StringTokenizer(l);
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] res = new int[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextInt();
      return res;
    }

    public long[] nextLongArray(int n) {
      long[] res = new long[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextLong();
      return res;
    }

    public double[] nextDoubleArray(int n) {
      double[] res = new double[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextDouble();
      return res;
    }

    public void sortIntArray(int[] array) {
      Integer[] vals = new Integer[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public void sortLongArray(long[] array) {
      Long[] vals = new Long[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public void sortDoubleArray(double[] array) {
      Double[] vals = new Double[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public String[] nextStringArray(int n) {
      String[] vals = new String[n];
      for (int i = 0; i < n; i++)
        vals[i] = next();
      return vals;
    }

    public Integer nextInteger() {
      String s = next();
      if (s == null)
        return null;
      return Integer.parseInt(s);
    }

    public int[][] nextIntMatrix(int n, int m) {
      int[][] ans = new int[n][];
      for (int i = 0; i < n; i++)
        ans[i] = nextIntArray(m);
      return ans;
    }

    public char[][] nextGrid(int r) {
      char[][] grid = new char[r][];
      for (int i = 0; i < r; i++)
        grid[i] = next().toCharArray();
      return grid;
    }

    public static <T> T fill(T arreglo, int val) {
      if (arreglo instanceof Object[]) {
        Object[] a = (Object[]) arreglo;
        for (Object x : a)
          fill(x, val);
      } else if (arreglo instanceof int[])
        Arrays.fill((int[]) arreglo, val);
      else if (arreglo instanceof double[])
        Arrays.fill((double[]) arreglo, val);
      else if (arreglo instanceof long[])
        Arrays.fill((long[]) arreglo, val);
      return arreglo;
    }

    public <T> T[] nextObjectArray(Class<T> clazz, int size) {
      @SuppressWarnings("unchecked")
      T[] result = (T[]) java.lang.reflect.Array.newInstance(clazz, size);
      for (int c = 0; c < 3; c++) {
        Constructor<T> constructor;
        try {
          if (c == 0)
            constructor = clazz.getDeclaredConstructor(Scanner.class,
                Integer.TYPE);
          else if (c == 1)
            constructor = clazz.getDeclaredConstructor(Scanner.class);
          else
            constructor = clazz.getDeclaredConstructor();
        } catch (Exception e) {
          continue;
        }
        try {
          for (int i = 0; i < result.length; i++) {
            if (c == 0)
              result[i] = constructor.newInstance(this, i);
            else if (c == 1)
              result[i] = constructor.newInstance(this);
            else
              result[i] = constructor.newInstance();
          }
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
        return result;
      }
      throw new RuntimeException("Constructor not found");
    }

    public void printLine(int... vals) {
      if (vals.length == 0)
        System.out.println();
      else {
        System.out.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          System.out.print(" ".concat(String.valueOf(vals[i])));
        System.out.println();
      }
    }

    public void printLine(long... vals) {
      if (vals.length == 0)
        System.out.println();
      else {
        System.out.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          System.out.print(" ".concat(String.valueOf(vals[i])));
        System.out.println();
      }
    }

    public void printLine(double... vals) {
      if (vals.length == 0)
        System.out.println();
      else {
        System.out.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          System.out.print(" ".concat(String.valueOf(vals[i])));
        System.out.println();
      }
    }

    public void printLine(int prec, double... vals) {
      if (vals.length == 0)
        System.out.println();
      else {
        System.out.printf("%." + prec + "f", vals[0]);
        for (int i = 1; i < vals.length; i++)
          System.out.printf(" %." + prec + "f", vals[i]);
        System.out.println();
      }
    }

    public Collection<Integer> wrap(int[] as) {
      ArrayList<Integer> ans = new ArrayList<Integer>();
      for (int i : as)
        ans.add(i);
      return ans;
    }

    public int[] unwrap(Collection<Integer> collection) {
      int[] vals = new int[collection.size()];
      int index = 0;
      for (int i : collection)
        vals[index++] = i;
      return vals;
    }
  }
}