#include using namespace std; const long long mod = 998244353; int main(){ int N, K; cin >> N >> K; vector G(K, vector(N, vector(N, 0LL))); for(int i = 0;i < K;i++){ int t; cin >> t; for(int j = 0;j < t;j++){ int a, b; cin >> a >> b; --a;--b; G[i][a][b] += 1; G[i][b][a] += 1; } } vector> dp(N+1, vector(1< cnt(K); for(int j = 0;j < K;j++){ for(int k = 0;k < i;k++){ cnt[j] += G[j][k][i]; cnt[j] %= mod; } } for(int j = 0;j < 1<