#include const int Mod = 998244353; const int bit[13] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096}; int main() { int i, j, k, l, N, C, cur, prev; long long dp[2][4096] = {}; scanf("%d", &N); for (i = 1, dp[0][bit[12]-1] = 1, cur = 1, prev = 0; i <= N; i++, cur ^= 1, prev ^= 1) { scanf("%d", &k); for (j = 1, l = 0; j <= k; j++) { scanf("%d", &C); l |= bit[C-1]; } for (k = 0; k < bit[12]; k++) { dp[prev][k] %= Mod; dp[cur][k] += dp[prev][k]; dp[cur][k&l] += dp[prev][k]; dp[prev][k] = 0; } } printf("%lld\n", dp[prev][0] % Mod); fflush(stdout); return 0; }