#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- ll ext_gcd(ll p,ll q,ll& x, ll& y) { // get px+qy=gcd(p,q) if(q==0) return x=1,y=0,p; ll g=ext_gcd(q,p%q,y,x); y-=p/q*x; return g; } pair crt(ll a1,ll mo1,ll a2,ll mo2) { // return (x,y) y=lcm(a1,a2),x%mo1=a1,x%mo2=a2 ll g,x,y,z; g=ext_gcd(mo1,mo2,x,y); a1=(a1%mo1+mo1)%mo1;a2=(a2%mo2+mo2)%mo2; if(a1%g != a2%g) return pair(-1,0); // N/A __int128_t lcm=mo1*(mo2/g); if(lcm(-2,0); // overflow __int128_t v=a1+((a2-a1)%lcm+lcm)*x%lcm*(mo1/g); return make_pair(((v%lcm)+lcm) % lcm,lcm); } int N,M; int X[6]; int dp[10100000]; vector P={168647939,592951213}; vector> C; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; FOR(i,M) cin>>X[i]; FORR(p,P) { dp[0]=dp[1]=1; for(i=2;i<=(N+1)/2;i++) { dp[i]=0; FOR(j,M) if(i>X[j]) dp[i]+=dp[i-X[j]]; dp[i]%=p; } ll ret=0; for(i=1;i<=(N+1)/2;i++) FOR(j,5) if(i+X[j]>(N+1)/2 && i+X[j]<=N) (ret+=dp[i]*dp[N-(i+X[j])])%=p; C.push_back({ret,p}); } auto ret=crt(C[0].first,C[0].second,C[1].first,C[1].second); cout<