using Y=bool;using an=__uint128_t;using ay=void;using az=unsigned char;using aB=unsigned;using aC=char;using aD=long double;using aF=__int128_t; #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 #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 #include #include #include #include #include #include #include #define aG return #define aO template #define aP constexpr #define aQ const #define cc class #define cd static_cast #define cH operator #define cI int #define cJ using #define dE namespace #define et typename #define eu struct #define ev false #define ew while #define ex friend #define ey static #define ez inline #define eA true #define eB continue #define eC auto #define eD for #define eE decltype #define eF this #define eG private #define eH else #define eI explicit #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 #include #include #include #include #include #include #include #include #include #include #include aOcJ aE=std::pair; #include #include #include aOcJ o=std::vector; #include #include #include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif #define dump(...) #define CPP_DUMP_SET_OPTION(...) #define CPP_DUMP_DEFINE_EXPORT_OBJECT(...) #define CPP_DUMP_DEFINE_EXPORT_ENUM(...) #define CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(...) dE J{dE aJ{dE z{aOeu cw:std::false_type{};aOeu cw())),eE(std::end(std::declval()))>>:std::true_type{};aOez aP Y aS=cw::value;aOcJ cS=eE(*std::begin(std::declval()));aOcJ dc=std::remove_cv_t>>;aOeu ci{cJ type=dc;};aOeu ci>::value_type>>{cJ type=et std::remove_cv_t>::value_type;};aOcJ cf=et ci::type;aOeu cr:std::false_type{};aOeu cr:std::bool_constant,aC>>{};aOeu cZ:std::bool_constant,std::string>||std::is_same_v,aQ aC*>||std::is_same_v,aC*>||cr>::value>{};aOez aP Y bm=cZ::value;aOeu cp:std::false_type{};aOeu cp().val())>>:std::true_type{};aOez aP Y cm=cp::value;aOeu ch:std::false_type{};aOeu ch()))>>:std::true_type{};aOez aP Y cN=ch::value;aOez aP Y bp=std::is_integral_v||std::is_same_v,aF>||std::is_same_v,an>;aOez aP Y bC=std::is_signed_v||std::is_same_v,aF>;aOeu bA{cJ type=std::make_unsigned_t;};aO<>eu bA{cJ type=an;};aO<>eu bA{cJ type=an;};aOcJ cW=et bA>::type;}eu aA{ey aP cI ai=1<<20;eG:std::FILE*aL;aC D[ai];cI r;cI O;cI bl;Y bD;Y cA(){r=0;if(bD){ssize_t length;do{length=::read(bl,D,ai);}ew(length<0&&errno==EINTR);if(length<=0){O=0;aG ev;}O=cI(length);}eH{O=cI(std::fread(D,1,ai,aL));}aG O!=0;}aOY cK(T&h){if(!bq())aG ev;cI c=V();Y W=ev;if(c=='-'){W=eA;c=V();}if aP(z::bC){T f=0;ew('0'<=c&&c<='9'){f=W?f*10-(c-'0'):f*10+(c-'0');c=V();}h=f;}eH{T f=0;ew('0'<=c&&c<='9'){f=f*10+T(c-'0');c=V();}h=W?T(0)-f:f;}aG eA;}Y da(){if(O-r>=64)aG eA;aQ cI be=O-r;if(be>0)std::memmove(D,D+r,be);aQ cI dq=cI(std::fread(D+be,1,ai-be,aL));r=0;O=be+dq;if(O=0&&::fstat(bl,&cB)==0&&!S_ISREG(cB.st_mode);}()){}aA(aQ aA&)=delete;aA&cH=(aQ aA&)=delete;cI V(){if(r==O&&!cA())aG EOF;aG D[r++];}Y bq(){cI c=V();ew(c!=EOF&&c<=' ')c=V();if(c==EOF)aG ev;--r;aG eA;}Y read(aC&h){if(!bq())aG ev;h=aC(V());aG eA;}Y read(std::string&h){if(!bq())aG ev;h.clear();ew(eA){aQ cI begin=r;ew(r(D[r])>' '){++r;}h.append(D+begin,r-begin);if(rstd::enable_if_t&&!std::is_same_v,Y>&&!std::is_same_v,aC>,Y>read(T&h){if(bD)aG cK(h);if(!da())aG ev;cI c=cd(D[r++]);ew(c<=' ')c=cd(D[r++]);Y W=ev;if(c=='-'){W=eA;c=cd(D[r++]);}if aP(z::bC){T f=0;ew('0'<=c&&c<='9'){aQ cI l=c-'0';aQ cI m=cd(D[r])-'0';if(0<=m&&m<=9){f=W?f*100-(l*10+m):f*100+(l*10+m);++r;}eH{f=W?f*10-l:f*10+l;}c=cd(D[r++]);}h=f;}eH{T f=0;ew('0'<=c&&c<='9'){aQ aB l=aB(c-'0');aQ cI m=cd(D[r])-'0';if(0<=m&&m<=9){f=f*100+T(l*10+aB(m));++r;}eH{f=f*10+T(l);}c=cd(D[r++]);}h=W?T(0)-f:f;}if(r>O)r=O;aG eA;}aOstd::enable_if_t,Y>read(T&h){if(!bq())aG ev;cI c=V();Y W=ev;if(c=='-'||c=='+'){W=c=='-';c=V();}aD f=0;ew('0'<=c&&c<='9'){f=f*10+(c-'0');c=V();}if(c=='.'){aD cC=0.1L;c=V();ew('0'<=c&&c<='9'){f+=(c-'0')*cC;cC*=0.1L;c=V();}}if(c=='e'||c=='E'){c=V();Y ck=ev;if(c=='-'||c=='+'){ck=c=='-';c=V();}cI Z=0;ew('0'<=c&&c<='9'){Z=Z*10+(c-'0');c=V();}aD aX=1;aD aW=10;ew(Z>0){if(Z&1)aX*=aW;aW*=aW;Z>>=1;}f=ck?f/aX:f*aX;}h=cd(W?-f:f);aG eA;}aOstd::enable_if_t&&!z::bp&&!z::aS,Y>read(T&h){long long x;if(!read(x))aG ev;if aP(z::cN){if(x>=0&&uint64_t(x)Y read(aE&h){if(!read(h.first))aG ev;aG read(h.second);}aOstd::enable_if_t&&!z::bm,Y>read(av&bV){cJ aH=z::cf;aP Y bt=z::aS&&!z::bm;eD(eC&&h:bV){if aP(std::is_same_v&&!bt){Y x;if(!read(x))aG ev;h=x;}eH{if(!read(h))aG ev;}}aG eA;}aOY read(aM&l,bg&m,bX&...rest){if(!read(l))aG ev;aG read(m,rest...);}aOaA&cH>>(T&h){if(!read(h))std::abort();aG*eF;}};eu as{ey aP cI ai=1<<20;eG:ez ey aQ eC ct=[]{std::arrayf{};eD(cI i=0;i<10000;i++){cI h=i;eD(cI j=3;j>=0;j--){f[4*i+j]=aC('0'+h%10);h/=10;}}aG f;}();std::FILE*aL;aC D[ai];cI r;cI bc;std::chars_format bo;aC bz;public:eI as(std::FILE*bu=stdout):aL(bu),r(0),bc(6),bo(std::chars_format::general),bz(' '){}as(aQ as&)=delete;as&cH=(aQ as&)=delete;~as(){bv();}ay bv(){if(r!=0){std::fwrite(D,1,r,aL);r=0;}std::fflush(aL);}ay aj(aC c){if(r==ai)bv();D[r++]=c;}ay P(aQ aC*s){ew(*s!='\0')aj(*s++);}ay P(aQ std::string&s){std::size_t ae=0;ew(ae(ai-r,s.size()-ae);std::memcpy(D+r,s.data()+ae,bL);r+=cI(bL);ae+=bL;}}ay P(aC c){aj(c);}ay P(Y h){aj(h?'1':'0');}aOstd::enable_if_t>P(T h){aC aU[128];eC[end,ds]=std::to_chars(aU,aU+sizeof(aU),h,bo,bc);if(ds!=std::errc())std::abort();eD(aQ aC*bH=aU;bH!=end;bH++){aj(*bH);}}aOstd::enable_if_t&&!std::is_same_v,Y>&&!std::is_same_v,aC> >P(T h){cJ cF=std::remove_cv_t;cJ bf=z::cW;bf ad;if aP(z::bC){if(h<0){aj('-');ad=bf(0)-bf(h);}eH{ad=bf(h);}}eH{ad=h;}if(ad==0){aj('0');aG;}aB cz[16];cI bS=0;ew(ad>=10000){aQ bf H=ad/10000;cz[bS++]=aB(ad-H*10000);ad=H;}if(r>ai-64)bv();aQ aB br=aB(ad);aQ aC*l=ct.data()+4*br;cI bZ=br<10?3:br<100?2:br<1000?1:0;eD(;bZ<4;bZ++)D[r++]=l[bZ];ew(bS--){aQ aC*aU=ct.data()+4*cz[bS];std::memcpy(D+r,aU,4);r+=4;}}aOstd::enable_if_t&&!z::bp&&!z::aS >P(aQ T&h){P(h.val());}aOay P(aQ aE&h){P(h.first);aj(' ');P(h.second);}aOstd::enable_if_t&&!z::bm >P(aQ av&bV){cJ aH=z::cf;aP Y bt=z::aS&&!z::bm;Y l=eA;eD(aQ eC&h:bV){if(!l)aj(bt?'\n':bz);l=ev;if aP(std::is_same_v&&!bt){P(cd(h));}eH{P(h);}}}aOay bU(aQ aM&l,aQ bX&...rest){P(l);((aj(' '),P(rest)),...);}ay println(){aj('\n');}ay dI(cI bd){bc=bd;}ay dR(cI bd=6){bo=std::chars_format::fixed;bc=bd;}ay dL(cI bd=6){bo=std::chars_format::general;bc=bd;}ay dF(aC dj){bz=dj;}aOay println(aQ Args&...args){bU(args...);aj('\n');}aOas&cH<<(aQ T&h){P(h);aG*eF;}};}}cJ dE std;dE J{dE ao{ez aJ::aA&bi(){ey aJ::aA bF;aG bF;}ez aJ::as&ap(){ey aJ::as bF;aG bF;}}}cJ ll=long long;cJ ba=unsigned cI;cJ bb=unsigned long long;cJ bY=__int128;cJ ek=unsigned __int128; #ifdef __SIZEOF_FLOAT128__ cJ eg=__float128; #endif aOaP T X=0;aO<>aP cI X =1'000'000'000;aO<>aP ll X =ll(X)*X*2;aO<>aP ba X =X;aO<>aP bb X =X;aO<>aP bY X =bY(X)*X;aO<>aP double X =X;aO<>aP aD X =X;cJ pi=pair;cJ pl=pair;cJ vi=vector;cJ vl=vector;aOcJ vc=vector;aOcJ cb=vector>;cJ er=cb;cJ es=cb;aOcJ dy=vector>;aOcJ dx=vector>;aOcJ dY=vector>;aOcJ eq=std::priority_queue,greater>;aOcJ el=unordered_map; #define vv(type, name, h, ...) vector> name(h, vector(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector>> name(h, vector>(w, vector(__VA_ARGS__))) #define vvvv(type, name, a, b, c, ...) vector>>> name( a, vector>>(b, vector>(c, vector(__VA_ARGS__)))) #define overload4(a, b, c, d, e, ...) e #define overload3(a, b, c, d, ...) d #define FOR1(a) for (ll _ = 0; _ < (ll)a; ++_) #define FOR2(i, a) for (ll i = 0; i < (ll)a; ++i) #define FOR3(i, a, b) for (ll i = a; i < (ll)b; ++i) #define FOR4(i, a, b, c) for (ll i = a; i < (ll)b; i += (c)) #define FOR1_R(a) for (ll i = (a) - 1; i >= 0; --i) #define FOR2_R(i, a) for (ll i = (a) - 1; i >= 0; --i) #define FOR3_R(i, a, b) for (ll i = (b) - 1; i >= (ll)a; --i) #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__) #define FORI1(a) for (int _ = 0; _ < (int)a; ++_) #define FORI2(i, a) for (int i = 0; i < (int)a; ++i) #define FORI3(i, a, b) for (int i = a; i < (int)b; ++i) #define FORI4(i, a, b, c) for (int i = a; i < (int)b; i += (c)) #define FORI1_R(a) for (int i = (a) - 1; i >= 0; --i) #define FORI2_R(i, a) for (int i = (a) - 1; i >= 0; --i) #define FORI3_R(i, a, b) for (int i = (b) - 1; i >= (int)a; --i) #define FORI(...) overload4(__VA_ARGS__, FORI4, FORI3, FORI2, FORI1)(__VA_ARGS__) #define FORI_R(...) overload3(__VA_ARGS__, FORI3_R, FORI2_R, FORI1_R)(__VA_ARGS__) #define FOR_subset(t, s) for (int t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s))) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() cI bP(cI x){aG __builtin_popcount(x);}cI bP(ba x){aG __builtin_popcount(x);}cI bP(ll x){aG __builtin_popcountll(x);}cI bP(bb x){aG __builtin_popcountll(x);}cI bB(cI x){aG __builtin_parity(x);}cI bB(ba x){aG __builtin_parity(x);}cI bB(ll x){aG __builtin_parityll(x);}cI bB(bb x){aG __builtin_parityll(x);}cI bQ(cI x){aG(x==0?-1:31-__builtin_clz(x));}cI bQ(ba x){aG(x==0?-1:31-__builtin_clz(x));}cI bQ(ll x){aG(x==0?-1:63-__builtin_clzll(x));}cI bQ(bb x){aG(x==0?-1:63-__builtin_clzll(x));}cI bN(cI x){aG(x==0?-1:__builtin_ctz(x));}cI bN(ba x){aG(x==0?-1:__builtin_ctz(x));}cI bN(ll x){aG(x==0?-1:__builtin_ctzll(x));}cI bN(bb x){aG(x==0?-1:__builtin_ctzll(x));}aOT bT(T a,T b){aG a/b-(a%b&&(a^b)<0);}aOT ef(T x,T y){aG bT(x+y-1,y);}aOT ee(T x,T y){aG x-y*bT(x,y);}aOpairbM(T x,T y){T q=bT(x,y);aG{q,x-q*y};}aOT em(U x_,cI n){T x=x_;T cG=1;ew(n>0){if(n&1)cG*=x;x*=x;n>>=1;}aG cG;}aOT en(aQ vector&A){T sm=0;eD(eC&&a:A)sm+=a;aG sm;} #define LB(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define UB(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit() aOez Y eb(T&a,aQ S&b){aG(aez Y ec(T&a,aQ S&b){aG(a>b?a=b,1:0);}vcdV(aQ string&S,aC de){vcA(S.size());FOR(i,S.size()){A[i]=(S[i]!='?'?S[i]-de:-1);}aG A;}aOvectordW(vector&A,cI dC=1){cI N=A.size();vectorB(N+1);FOR(i,N){B[i+1]=B[i]+A[i];}if(dC==0)B.erase(B.begin());aG B;}aOvectordT(aQ vector&A){vectorca(A.size());iota(all(ca),0);sort(all(ca),[&](cI i,cI j){aG(A[i]==A[j]?ivcdQ(aQ vc&A,aQ vc&I){vcB(I.size());FOR(i,I.size())B[i]=A[I[i]];aG B;}aOaP eC dB(T...a){aG dB(initializer_list>{a...});}aOaP eC dA(T...a){aG dA(initializer_list>{a...});}aOY cD(Ts&...values){aG J::ao::bi().read(values...);}aOay bU(aQ Ts&...values){J::ao::ap().println(values...);}ay dZ(Y b){J::ao::ap().println(b?"YES":"NO");}ay ea(Y b){J::ao::ap().println(b?"Yes":"No");}ay eo(){J::ao::ap().println("YES");}ay NO(){J::ao::ap().println("NO");}ay ep(){J::ao::ap().println("Yes");}ay No(){J::ao::ap().println("No");}dE J{dE aV{aOeu bW{cJ dh=T;cI ax;cI R;T ah;cI C;Y aw;bW():ax(-1),R(-1),ah(T()),C(-1),aw(eA){}bW(cI dt,cI dD,T dr=T(1),cI dz=-1,Y dn=eA):ax(dt),R(dD),ah(dr),C(dz),aw(dn){}cI aq(cI v)aQ{(ay)0;aG ax^R^v;}};aOeu au{cJ ak=bW;cJ dh=T;eG:cI _n;cI ab;o>K;o>>ar;public:au():_n(0),ab(0){}eI au(cI n):_n(n),ab(0),K(n){(ay)0;}cI size()aQ{aG _n;}Y empty()aQ{aG _n==0;}cI dN()aQ{aG ab;}cI dM(){K.emplace_back();aG _n++;}cI dG(cI ax,cI R,T ah=T(1)){(ay)0;(ay)0;cI C=ab++;cI aN=cI(K[ax].size());K[ax].push_back(ak(ax,R,ah,C));ar.emplace_back();ar.back().push_back({ax,aN});aG C;}cI add_edge(cI u,cI v,T ah=T(1)){(ay)0;(ay)0;cI C=ab++;cI dv=cI(K[u].size());K[u].push_back(ak(u,v,ah,C));cI dw=cI(K[v].size());K[v].push_back(ak(v,u,ah,C));ar.emplace_back();ar.back().push_back({u,dv});ar.back().push_back({v,dw});aG C;}ay cq(cI C,Y aw){(ay)0;eD(eC[v,aN]:ar[C]){K[v][aN].aw=aw;}}ay dO(cI C){cq(C,ev);}ay dK(cI C){cq(C,eA);}Y dH(cI C)aQ{(ay)0;(ay)0;eC[v,aN]=ar[C][0];aG K[v][aN].aw;}aQ o&cH[](cI v)aQ{(ay)0;aG K[v];}o&cH[](cI v){(ay)0;aG K[v];}aQ o>&dg()aQ{aG K;}o>&dg(){aG K;}oed(Y cU=ev)aQ{of;f.reserve(ab);ocE(ab,ev);eD(cI v=0;v<_n;v++){eD(aQ eC&e:K[v]){if(!cU&&!e.aw)eB;if(0<=e.C&&e.Ceu aR{oaa;oaT;obO;ocu;T aZ=T();Y reachable(cI v)aQ{(ay)0;aG aT[v];}oei(cI t)aQ{(ay)0;of;eD(cI v=t;v!=-1;v=bO[v])f.push_back(v);std::reverse(f.begin(),f.end());aG f;}};dE z{aOeu by{T aa;cI bR;};aOeu cM{Y cH()(aQ by&l,aQ by&m)aQ{aG m.aaaRaK(aQ au&g,aQ o&bK){cI n=g.size();aRf;f.aa.resize(n);f.aT.assign(n,ev);f.bO.assign(n,-1);f.cu.assign(n,-1);cJ bj=z::by;cJ dm=z::cM;std::priority_queue,dm>bk;eD(cI s:bK){(ay)0;if(f.aT[s])eB;f.aT[s]=eA;f.aa[s]=T();bk.push(bj{T(),s});}ew(!bk.empty()){bj L=bk.top();bk.pop();if(f.aa[L.bR]aRaK(aQ au&g,cI s){aG aK(g,o{s});}aOaRaK(aQ au&g,aQ o&bK,aQ T&aZ){aRf=aK(g,bK);f.aZ=aZ;eD(cI v=0;vaRaK(aQ au&g,cI s,aQ T&aZ){aG aK(g,o{s},aZ);}}}dE J{dE aJ{dE dp{aOcc k{eG:ey aP std::size_t ac=bx/64;cJ F=std::array;public:ey aP std::size_t dP=bx;aP k()=default;aOaP k(cx h){if aP(std::signed_integral){aQ std::uint64_t di=h<0?~std::uint64_t(0):std::uint64_t(0);E.fill(di);E[0]=cd(cd(h));}eH{E[0]=cd(h);}}eI k(std::string_view Q){read(Q);}k&cH=(std::string_view Q){read(Q);aG*eF;}ay read(std::string_view Q){if(Q.empty()){throw std::invalid_argument("empty fixed-width integer");}aQ Y W=Q.front()=='-';std::size_t ae=(Q.front()=='-'||Q.front()=='+')?1:0;if(ae==Q.size()){throw std::invalid_argument("invalid fixed-width integer");}k f;eD(;ae'9'){throw std::invalid_argument("invalid fixed-width integer");}f.multiply_unsigned_small(10);f+=k(cd(bh-'0'));}*eF=W?-f:f;}aP Y is_zero()aQ{eD(aQ std::uint64_t aY:E){if(aY!=0)aG ev;}aG eA;}aP Y is_negative()aQ{aG(E.back()>>63)!=0;}aP cI ej()aQ{if(is_zero())aG 0;aG is_negative()?-1:1;}aP k cH+()aQ{aG*eF;}aP k cH-()aQ{k f;f.E=E;cn(f.E);aG f;}aP k&cH+=(aQ k&aq){an am=0;eD(std::size_t w=0;w(L);am=L>>64;}aG*eF;}aP k&cH-=(aQ k&aq){aG*eF+=-aq;}aP k&cH*=(aQ k&aq){F bI{};eD(std::size_t l=0;l(L);am=L>>64;}}E=bI;aG*eF;}aP k&multiply_small(std::uint64_t h){multiply_unsigned_small(h);aG*eF;}aP k&cH/=(aQ k&aq){aG*eF=bM(*eF,aq).first;}aP k&cH%=(aQ k&aq){aG*eF=bM(*eF,aq).second;}std::string to_string()aQ{if(is_zero())aG"0";aQ Y W=is_negative();F ad=unsigned_magnitude();std::string f;ew(!cQ(ad)){aQ aB bh=cL(ad);f.push_back(cd('0'+bh));}if(W)f.push_back('-');std::reverse(f.begin(),f.end());aG f;}ex aP aEbM(aQ k&at,aQ k&af){if(af.is_zero()){throw std::domain_error("fixed-width integer division by zero");}aQ Y cR=at.is_negative()!=af.is_negative();aQ Y cO=at.is_negative();eC[bn,cX]=cV(at.unsigned_magnitude(),af.unsigned_magnitude());k H;k G;H.E=bn;G.E=cX;if(cR)H=-H;if(cO)G=-G;aG std::make_pair(H,G);}ex aP aEcs(aQ k&at,std::uint32_t af){if(af==0){throw std::domain_error("fixed-width integer division by zero");}F bn=at.unsigned_magnitude();aQ std::uint64_t cj=ce(bn,af);k H;H.E=bn;if(at.is_negative())H=-H;aQ std::int64_t G=at.is_negative()?-std::int64_t(cj):std::int64_t(cj);aG std::make_pair(H,G);}ex aP k cH+(k l,aQ k&m){aG l+=m;}ex aP k cH-(k l,aQ k&m){aG l-=m;}ex aP k cH*(k l,aQ k&m){aG l*=m;}ex aP k cH/(k l,aQ k&m){aG l/=m;}ex aP k cH%(k l,aQ k&m){aG l%=m;}ex aP Y cH==(aQ k&l,aQ k&m)=default;ex aP Y cH<(aQ k&l,aQ k&m){aQ Y co=l.is_negative();aQ Y cY=m.is_negative();if(co!=cY)aG co;aG cl(l.E,m.E)<0;}ex aP Y cH!=(aQ k&l,aQ k&m){aG!(l==m);}ex aP Y cH>(aQ k&l,aQ k&m){aG m=(aQ k&l,aQ k&m){aG!(l>(std::istream&bi,k&h){std::string Q;if(bi>>Q)h.read(Q);aG bi;}eG:F E{};aP F unsigned_magnitude()aQ{F f=E;if(is_negative())cn(f);aG f;}aP ay multiply_unsigned_small(std::uint64_t h){an am=0;eD(std::size_t w=0;w(L);am=L>>64;}}ey aP ay cn(F&h){eD(std::uint64_t&aY:h)aY=~aY;eD(std::size_t w=0;w>63;h[w]=(h[w]<<1)|am;am=df;}}ey aP aEcV(aQ F&at,aQ F&af){F H{};F G{};eD(std::size_t al=0;al>(bit%64))&std::uint64_t(1);if(cl(G,af)>=0){cT(G,af);H[bit/64]|=std::uint64_t(1)<<(bit%64);}}aG std::make_pair(H,G);}ey Y cQ(aQ F&h){eD(aQ std::uint64_t aY:h){if(aY!=0)aG ev;}aG eA;}ey aP std::uint64_t ce(F&h,std::uint64_t af){an G=0;eD(std::size_t al=0;al(L/af);G=L%af;}aG cd(G);}ey aB cL(F&h){aG cd(ce(h,10));}};}}}dE J{dE aJ{cJ ag=dp::k<512>;cJ eh=ag;ez ag dJ(std::string_view Q){aG ag(Q);}ez std::string to_string(aQ ag&h){aG h.to_string();}}}eC&dX=J::ao::bi();eC&dU=J::ao::ap();cJ ag=J::aJ::ag;o>dd(){o>f;std::arraycv{};eD(cI p=2;p<=300;++p){if(cv[p])eB;eD(cI bG=p+p;bG<=300;bG+=p){cv[bG]=eA;}cI Z=0;cI aW=1;ew(aW<=300/p){aW*=p;++Z;}f.emplace_back(p,Z);}aG f;}ay du(){aQ o>cy=dd();ag cg=1;eD(eC[bw,Z]:cy){eD(cI i=0;iaX;eD(cI aI=1;aI<=300;++aI){eC[H,G]=cs(cg,aI);(ay)0;aX[aI]=H;}cI N,M;cD(N,M);J::aV::auaV(N);ew(M--){cI u,v,a,b;cD(u,v,a,b);--u;--v;ag ah=aX[b];ah.multiply_small(a);aV.add_edge(u,v,ah);}aQ eC dl=J::aV::aK(aV,0);eD(cI v=1;v