#include #include #include #include #include #include #include #include #include #include #include #include #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define RI(X) scanf("%d", &(X)) #define RII(X, Y) scanf("%d%d", &(X), &(Y)) #define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z)) #define DRI(X) int (X); scanf("%d", &X) #define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y) #define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z) #define RS(X) scanf("%s", (X)) #define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define PII pair #define VI vector #define VPII vector > #define PLL pair #define VPLL vector > #define F first #define S second typedef long long LL; using namespace std; const int MOD = 1e9+7; const int SIZE = 1e6+10; LL fac[SIZE],inv[SIZE]; void ADD(LL& x,LL v){ x=(x+v)%MOD; if(x<0)x+=MOD; } LL mypow(LL x,LL y){ LL res=1; while(y){ if(y&1)res=res*x%MOD; y>>=1; x=x*x%MOD; } return res; } LL C(int x,int y){ if(y<0||y>x)return 0; return fac[x]*inv[y]%MOD*inv[x-y]%MOD; } void build(){ fac[0]=1; REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD; inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2); for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD; } LL dp[66][66][66]; int main(){ build(); CASET{ MS0(dp); DRII(N,K); dp[0][1][1]=1; LL an=0; REP(i,K){ REPP(j,i+1,N+1){ REPP(k,1,j+1){ if(!dp[i][j][k])continue; // printf("dp[%d][%d][%d]=%I64d\n",i,j,k,dp[i][j][k]); ADD(an,dp[i][j][k]*mypow(2,C(N-j,2))); REPP(l,j+1,N+1){ ADD(dp[i+1][l][l-j],dp[i][j][k]*mypow(mypow(2,k)-1,l-j)%MOD*mypow(2,C(l-j,2))%MOD*C(N-j,N-l)); } } } } cout<