#include #include using mint = atcoder::modint998244353; using namespace std; using ll = long long; mint dp[1 << 12]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; dp[(1 << 12) - 1] = 1; for (int i = 0; i < n; i++) { int k; cin >> k; int t = 0; for (int j = 0; j < k; j++) { int c; cin >> c; c--; t ^= 1 << c; } for (int k = 0; k < 1 << 12; k++) { dp[k & t] += dp[k]; } } cout << dp[0].val() << endl; return 0; }