structGraph { int cnt; int head[N], nxt[N * 2], to[N * 2]; inlinevoidadd(int u, int v){ ++cnt, nxt[cnt] = head[u], to[cnt] = v, head[u] = cnt; ++cnt, nxt[cnt] = head[v], to[cnt] = u, head[v] = cnt; } } G;
int n; int size[N];
voiddfs(int u, int fa){ for (int i = G.head[u]; i; i = G.nxt[i]) { int v = G.to[i]; if (v == fa) continue; dfs(v, u); if (size[v] == 2) continue; size[u] += size[v]; } if (size[u] >= 2) { puts("First"); exit(0); } ++size[u]; }
inlinevoidmain(){ read(n); for (int i = 1; i < n; ++i) { int u, v; read(u), read(v); G.add(u, v); } dfs(1, 0); if (size[1] & 1) puts("First"); elseputs("Second"); }
constint N = 1e5 + 9; constint M = 109; constint P = 1e9 + 7; constint Lim = 1 << 4;
int T, n, m; int p[M], f[M][20], g[M], fac[N], ifac[N]; int prime[] = { 2, 3, 5, 7 }; vector<int> a[M];
inlinevoidclear(){ for (int i = 1; i <= m; ++i) a[i].clear(); memset(p, 0, sizeof p); memset(f, 0, sizeof f); memset(g, 0, sizeof g); }
inlinevoiddec(){ for (int i = 2; i <= m; ++i) { int t = i; for (int j = 0; j < 4; ++j) { int k = prime[j]; if (t % k) continue; p[i] |= 1 << j; while (t % k == 0) t /= k; } a[t].push_back(i); } }
intmain(){ int lm = 1e5; fac[0] = ifac[0] = 1; for (int i = 1; i <= lm; ++i) fac[i] = (LL)fac[i - 1] * i % P; ifac[lm] = power(fac[lm], P - 2); for (int i = lm - 1; i; --i) ifac[i] = (LL)ifac[i + 1] * (i + 1) % P;
cin >> T; while (T--) { clear(); cin >> n >> m; dec(); f[0][0] = 1; for (int i = 0; i < (int)a[1].size(); ++i) { int x = a[1][i]; for (int j = 30; j; --j) { for (int s = 0; s < Lim; ++s) { if ((s & p[x]) != p[x]) continue; f[j][s] = (f[j][s] + f[j - 1][s ^ p[x]]) % P; } } } for (int i = 2; i <= m; ++i) { if (a[i].empty()) continue; for (int j = 30; j; --j) { for (int s = 0; s < Lim; ++s) { for (int k = 0; k < (int)a[i].size(); ++k) { int x = a[i][k]; if ((s & p[x]) != p[x]) continue; f[j][s] = (f[j][s] + f[j - 1][s ^ p[x]]) % P; } } } } for (int i = 0; i <= 30; ++i) { for (int s = 0; s <= Lim; ++s) g[i] = (g[i] + f[i][s]) % P; } int ans = 0; for (int i = 0; i <= min(m, 30); ++i) { ans = (ans + (LL)g[i] * ifac[n - i]) % P; } ans = (LL)ans * fac[n] % P; cout << ans << endl; } return0; }