import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.*; public class Main { static int N; static ArrayList> edge; static long[] dp; static long[] cnt; static int mod = 1_000_000_007; public static void solve(int i) { if (dp[i] != -1) return; long val = 0; long val_cnt = 1; for (Integer tmp : edge.get(i)) { solve(tmp); val = (val+dp[tmp]+cnt[tmp])%mod; val_cnt += cnt[tmp]; } dp[i] = val; cnt[i] = val_cnt; } public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); N = in.nextInt(); edge = new ArrayList>(); for (int i=0;i add = new HashSet(); edge.add(add); } boolean[] not_root = new boolean[N]; for (int i=0;i