#include #include using namespace std; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector hashs(N); while (M--) { int l, a; cin >> l; while (l--) hashs.at((cin >> a, a - 1)) += 1U * (M + 1) * (M + 1) * (M + 1); } std::sort(hashs.begin(), hashs.end()); int cnt = 1; for (int i = 1; i < N; ++i) cnt += (hashs[i] != hashs[i - 1]); cout << atcoder::modint998244353(2).pow(cnt).val() << endl; }