#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const int MAXN = 100010; const int mod = 1e9 + 7; int T,n,K; int fac[MAXN],afac[MAXN],pw[10000]; int dp[70][70][70],C[200][200]; // //void Pre(){ // fac[0] = afac[0] = 1; // for(int i = 1; i < MAXN; ++i) fac[i] = 1ll * fac[i - 1] * i % mod; // afac[MAXN - 1] = Q_pow(fac[MAXN - 1],mod - 2); // for(int i = MAXN - 1; i > 1; --i) afac[i - 1] = 1ll * afac[i] * i % mod; //} int Q_pow(int x,int y){ int res = 1; while(y){ if(y & 1) res = 1ll * res * x % mod; x = 1ll * x * x % mod; y >>= 1; } return res; } int main(){ //Pre(); for(int i = 0; i < 200; ++i){ for(int j = 0; j <= i; ++j){ C[i][j] = (i == 0 || j == 0) ? 1 : (C[i - 1][j] + C[i - 1][j - 1]) % mod; } } pw[0] = 1; for(int i = 1; i < 10000; ++i){ pw[i] = 2ll * pw[i - 1] % mod; } scanf("%d",&T); while(T--){ scanf("%d%d",&n,&K); memset(dp,0,sizeof(dp)); dp[0][1][1] = 1; for(int i = 1; i < K; ++i){ for(int j = i; j <= n; ++j){ for(int q = i - 1; q < j; ++q){ // dp[i - 1][q] --> dp[i][j] int num = j - q; int tmp = num * (num - 1) / 2; for(int p = 1; p <= q - (i - 2); ++p){ // dp[i - 1][q][p] --> dp[i][j][j - q] dp[i][j][j - q] = (dp[i][j][j - q] + 1ll * dp[i - 1][q][p] * C[n - q][j - q] % mod * pw[tmp] % mod * Q_pow(pw[p] - 1,j - q) % mod) % mod; } } } } int ans = 0; for(int i = 0; i < K; ++i){ for(int j = i; j <= n; ++j){ int num = n - j; int tmp = num * (num - 1) / 2; for(int k = 1; k <= j - (i - 1); ++k){ //printf("dp[%d][%d][%d] : %d\n",i,j,k,dp[i][j][k]); ans = (ans + 1ll * dp[i][j][k] * pw[tmp] % mod) % mod; } } } printf("%d\n",ans); } return 0; }