#include #include using namespace std; using mint = atcoder::modint998244353; constexpr int D = 12; mint dp[1 << 12]; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; dp[(1 << 12) - 1] = 1; while (N--) { int k; cin >> k; int mask = 0; while (k--) { int c; cin >> c; c--; mask |= 1 << c; } for (int s = 0; s < 1 << 12; ++s)dp[s & mask] += dp[s]; } cout << dp[0].val() << '\n'; }