#include #include using namespace std; int main() { int N, M; cin >> N >> M; vector hashs(N); while (M--) { int l, a; cin >> l; while (l--) hashs.at((cin >> a, a - 1)) += 1LL * (M + 1) * (M + 1) * (M + 1); } cout << atcoder::modint998244353(2).pow(set(hashs.begin(), hashs.end()).size()).val() << endl; }