import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class ac_lewin { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); RedBlackTree solver = new RedBlackTree(); solver.solve(1, in, out); out.close(); } static class RedBlackTree { public static final int mod = 1000000007; List[] graph; boolean[] red; int[] order; int[] p; int oidx; void dfs(int node, int par) { p[node] = par; order[oidx++] = node; for (int next : graph[node]) if (next != par) dfs(next, node); } public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(), k = in.nextInt(); graph = LUtils.genArrayList(n); for (int i = 1; i < n; i++) { int a = in.nextInt() - 1; graph[i].add(a); graph[a].add(i); } red = new boolean[n]; for (int i = 0; i < k; i++) { red[in.nextInt() - 1] = true; } order = new int[n]; p = new int[n]; dfs(0, -1); long[] kk = new long[k + 1]; long[] vv = new long[n]; for (int i = 0; i <= k; i++) { Arrays.fill(vv, 1); for (int j = n - 1; j > 0; j--) { int node = order[j]; if (red[node]) vv[node] += i; else vv[node] += 1; vv[p[node]] = vv[p[node]] * vv[node] % mod; } if (red[0]) vv[0] += i; else vv[0] += 1; kk[i] = vv[0] % mod; } kk = Polynomial.interpolation(kk, mod); for (long x : kk) out.println(x); } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void close() { writer.close(); } public void println(long i) { writer.println(i); } } static class LUtils { public static List[] genArrayList(int size) { return Stream.generate(ArrayList::new).limit(size).toArray(List[]::new); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1 << 16]; private int curChar; private int numChars; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (this.numChars == -1) { throw new InputMismatchException(); } else { if (this.curChar >= this.numChars) { this.curChar = 0; try { this.numChars = this.stream.read(this.buf); } catch (IOException var2) { throw new InputMismatchException(); } if (this.numChars <= 0) { return -1; } } return this.buf[this.curChar++]; } } public int nextInt() { int c; for (c = this.read(); isSpaceChar(c); c = this.read()) { ; } byte sgn = 1; if (c == 45) { sgn = -1; c = this.read(); } int res = 0; while (c >= 48 && c <= 57) { res *= 10; res += c - 48; c = this.read(); if (isSpaceChar(c)) { return res * sgn; } } throw new InputMismatchException(); } public static boolean isSpaceChar(int c) { return c == 32 || c == 10 || c == 13 || c == 9 || c == -1; } } static class Polynomial { public static long[] interpolation(long[] y, int mod) { int n = y.length; long[] a = new long[n], b = new long[n]; a[0] = y[0]; b[0] = 1; long[] inv = new long[n + 1]; inv[1] = 1; for (int i = 2; i <= n; i++) { inv[i] = (mod - mod / i) * inv[mod % i] % mod; } for (int i = 1; i < n; i++) { for (int j = 0; j + i < n; j++) y[j] = (y[j + 1] - y[j] + mod) % mod * inv[i] % mod; for (int j = i; j > 0; j--) b[j] = (b[j - 1] + (mod - i + 1) * b[j]) % mod; b[0] = b[0] * (mod - i + 1) % mod; for (int j = 0; j <= i; j++) { a[j] = (a[j] + b[j] * y[0]) % mod; } } return a; } } }