import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] k = new int[n]; int[] c = new int[n]; for (int i = 0; i < n; i++) { k[i] = sc.nextInt(); for (int j = 0; j < k[i]; j++) { c[i] += 1 << (sc.nextInt() - 1); } } sc.close(); int mod = 998244353; int m = 1 << 12; long[] dp = new long[m]; for (int i = 0; i < n; i++) { long[] wk = new long[m]; for (int j = 0; j < m; j++) { wk[j] += dp[j]; wk[j & c[i]] += dp[j]; } wk[c[i]]++; for (int j = 0; j < m; j++) { wk[j] %= mod; } dp = wk; } System.out.println(dp[0]); } }