#include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint INF = 1e9; int t; const ll mod = 998244353; ll n; ll qpow(ll a,ll b) { ll res = 1; while(b) { if(b & 1) res =res * a % mod; a = a * a % mod; b >>= 1; } return res; }
intmain() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> t; ll st = 1; while(t--) { cin >> n; ll ans = qpow(2,n - 1); ans -= 1; ans = ((ans % mod) + mod) % mod; cout << ans << '\n'; } return0; }
using i64 = int64_t; constexprint N = 1005; std::bitset<N> bt[N]; constexpr i64 mod = 1e9 + 7;
i64 fpow(i64 x, i64 r) { i64 result = 1; while (r) { if (r & 1)result = result * x % mod; r >>= 1; x = x * x % mod; } return result; }
namespace binom { i64 fac[N], ifac[N]; int __ = [] { fac[0] = 1; for (int i = 1; i <= N - 5; i++) fac[i] = fac[i - 1] * i % mod; ifac[N - 5] = fpow(fac[N - 5], mod - 2); for (int i = N - 5; i; i--) ifac[i - 1] = ifac[i] * i % mod; return0; }();
inline i64 C(int n, int m) { if (n < m || m < 0)return0; return fac[n] * ifac[m] % mod * ifac[n - m] % mod; }
inline i64 A(int n, int m) { if (n < m || m < 0)return0; return fac[n] * ifac[n - m] % mod; } } usingnamespace binom; usingnamespace std; intmain() { std::ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { int n, m; std::cin >> n >> m; for (int i = 1; i <= n; i++) bt[i].reset(); while (m--) { int u, v; std::cin >> u >> v; bt[u][v] = bt[v][u] = 1; } i64 ans = 0; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) { int cnt_i = bt[i].count(); int cnt_j = bt[j].count(); int cnt = (bt[i] & bt[j]).count(); if (bt[i][j]) cnt_i--, cnt_j--; ans = (ans + C(cnt, 4) * C(cnt_i - 4, 2) + C(cnt, 4) * C(cnt_j - 4, 2)) % mod; } cout << ans << '\n'; } return0; }