import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable long MOD = 998244353; void main() { auto N = readln.chomp.to!int; auto A = new int[](N); foreach (i; 0..N) { auto s = readln.split.map!(to!int).array; foreach (a; s[1..$]) { A[i] |= (1 << a); } } auto dp = new long[][](N+1, 1<<13); dp[0][(1<<13)-1] = 1; foreach (i; 0..N) foreach (mask; 0..(1<<13)) { (dp[i+1][mask & A[i]] += dp[i][mask]) %= MOD; (dp[i+1][mask] += dp[i][mask]) %= MOD; } dp[N][0].writeln; }