#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>; #define MAX 20005 //#define MOD 1000000007 #define MOD 998244353 //#define INF 1000000000 #define INF 1000000000000000000 int main(){ int N; cin>>N; vector k(N); vector> C(N); vector A(N); for(int i=0;i>k[i]; C[i].resize(k[i]); for(int j=0;j>C[i][j]; C[i][j]--; A[i]+=(1<> dp(N+1,vector(1< sum(1<