import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; class DJSet { int n; int[] upper; public DJSet(int n_) { n=n_; upper=new int[n]; Arrays.fill(upper, -1); } int root(int x) { return upper[x]<0?x:(upper[x]=root(upper[x])); } boolean equiv(int x,int y) { return root(x)==root(y); } void setUnion(int x,int y) { x=root(x); y=root(y); if (x==y) return; if (upper[x]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,long C) { for (int curc=1;curcC||nextc>=dp[dst].length) 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(); DJSet ds=new DJSet(N); assert(2<=N&&N<=1000); long C=sc.nextInt(); assert(4<=C&&C<=1e9); 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