import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { new Main().run(); } long pow(long a,long n) { long ret=1; for (;n>0;n>>=1,a=a*a%MOD) if (n%2==1) ret=ret*a%MOD; return ret; } void dfs(int cur,int par,ArrayList[] g,int C,int max) { for (int curc=1;curc<=max;++curc) { dp[cur][curc]=1; } for (int dst:g[cur]) { if (dst==par) continue; dfs(dst,cur,g,C,max); for (int curc=1;curcC) continue; sum+=dp[dst][nextc]; sum%=MOD; } dp[cur][curc]*=sum; dp[cur][curc]%=MOD; } } } final long MOD=(long)1e9+7; int MAXN=3000; long[][] dp=new long[MAXN][3*MAXN+1]; void run() { FastScanner sc=new FastScanner(); int N=sc.nextInt(); int C=sc.nextInt(); int[] a=new int[N-1]; int[] b=new int[N-1]; ArrayList[] g=new ArrayList[N]; for (int i=0;i(); for (int i=0;i