#include "atcoder/modint.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const long long int INF = numeric_limits::max() / 4; const int inf = numeric_limits::max() / 4; const long long int MOD1000000007 = 1000000007; const long long int MOD998244353 = 998244353; const double MATH_PI = 3.1415926535897932; template inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; } template inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; } #define lint long long int #define ALL(a) a.begin(),a.end() #define RALL(a) a.rbegin(),a.rend() #define rep(i, n) for(int i=0;i<(int)(n);i++) #define VI vector #define VLL vector #define VC vector #define VB vector #define PI pair #define PLL pair #define VPI vector> #define VPLL vector> #define VVI vector> #define VVPI vecor>> #define VVPILL vector>> #define SUM(v) accumulate(ALL(v), 0LL) #define MIN(v) *min_element(ALL(v)) #define MAX(v) *max_element(ALL(v)) using mint = atcoder::modint998244353; int main() { int n; cin >> n; int w = 12; vector dp(1 << w, 0); for (int i = 0; i < n; i++) { int k; cin >> k; int bit = 0; for (int j = 0; j < k; j++) { int c; cin >> c; c--; bit |= (1 << c); } vector ndp(1 << w, 0); ndp[bit] = 1; for (int bbit = 0; bbit < (1 << w); bbit++) { if (dp[bbit] == 0) continue; ndp[bbit] += dp[bbit]; ndp[bbit & bit] += dp[bbit]; } swap(dp, ndp); } cout << dp[0].val() << endl; return 0; }