#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n,m; cin>>n>>m; vector> B(m); rep(i,m){ int l; cin>>l; rep(j,l){ int a; cin>>a; B[i][a-1] = 1; } } m++; B.push_back(bitset<1001>()); rep(i,m){ B.push_back(B[i].flip()); } vector> t; rep(i,n){ bitset<1001> tt; tt.flip(); rep(j,B.size()){ if(B[j][i])tt &= B[j]; } t.push_back(tt); } mint ans = 1; rep(i,t.size()){ bool f = true; rep(j,i){ if(t[i]==t[j])f = false; } if(f)ans *= 2; } cout<