#define MD 998244353 ll@n++,@m; ll p[n]; rep(i,n)p[i]=i; rep(m){ ll@t,@a,o=p[a]; rep(t-1){ ll@b; (o,p[b])=(p[b],o); } p[a]=o; } ll g=0,c=0; Mint z=1; rep(i,n){ if(p[i]>=0&&p[i]!=i){ ll j=i,a=0; while(p[j]>=0){ (p[j],j)=(-1,p[j]); ++a; } g=gcd(g,a); z*=a; ++c; } } wt(c?z/Mint(g)**(c-1):Mint(1));