#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 10000000000000000 int main(){ int n; cin>>n; vector a(n); rep(i,n){ int k; cin>>k; a[i] = 0; rep(j,k){ int x; cin>>x; x--; a[i] |= 1< dp(1<<12,0); dp.back() = 1; rep(i,n){ vector ndp(1<<12,0); rep(j,1<<12){ ndp[j] += dp[j]; ndp[j&a[i]] += dp[j]; } swap(dp,ndp); } cout<