#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); } cout << atcoder::modint998244353(2).pow(set(hashs.begin(), hashs.end()).size()).val() << endl; }