#include #include using namespace std; template T rd_integer() { T ret = 0; bool minus = false; char c = getchar_unlocked(); while (!isdigit(c)) minus |= (c == '-'), c = getchar_unlocked(); while (isdigit(c)) ret = (ret << 1) + (ret << 3) + (c ^ 48), c = getchar_unlocked(); return minus ? -ret : ret; } int rdi() { return rd_integer(); } long long rdll() { return rd_integer(); } std::string rdstr() { std::string ret; char c = getchar_unlocked(); while (!isgraph(c)) c = getchar_unlocked(); while (isgraph(c)) ret += c, c = getchar_unlocked(); return ret; } int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N = rdi(), M = rdi(); vector hashs(N); while (M--) { int l = rdi(); while (l--) hashs.at(rdi() - 1) += (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; }