varbigintModArith=function(n){"use strict";functiont(n){return(n=BigInt(n))>=0n?n:-n}functionr(n,t){if((n=BigInt(n))<=0n|(t=BigInt(t))<=0n)thrownewRangeError("a and b MUST be > 0");letr=0n,i=1n,e=1n,u=0n;for(;0n!==n;){consto=t/n,f=t%n,g=r-e*o,c=i-u*o;t=n,n=f,r=e,i=u,e=g,u=c}return{g:t,x:r,y:i}}functioni(n,r){if(n=t(n),r=t(r),0n===n)returnr;if(0n===r)returnn;leti=0n;for(;!(1n&(n|r));)n>>=1n,r>>=1n,i++;for(;!(1n&n);)n>>=1n;do{for(;!(1n&r);)r>>=1n;if(n>r){constt=n;n=r,r=t}r-=n}while(r);returnn<<i}functione(n,t){try{consti=r(u(n,t),t);return1n!==i.g?NaN:u(i.x,t)}catch(n){returnNaN}}functionu(n,t){return(t=BigInt(t))<=0?NaN:(n=BigInt(n)%t)<0?n+t:n}returnn.abs=t,n.bitLength=function(n){if(1n===(n=BigInt(n)))return1;lett=1;do{t++}while((n>>=1n)>1n);returnt},n.eGcd=r,n.gcd=i,n.lcm=function(n,r){returnn=BigInt(n),r=BigInt(r),0n===n&&0n===r?BigInt(0):t(n*r)/i(n,r)},n.max=function(n,t){return(n=BigInt(n))>=(t=BigInt(t))?n:t},n.min=function(n,t){return(n=BigInt(n))>=(t=BigInt(t))?t:n},n.modInv=e,n.modPow=functionn(r,i,o){if(0n===(o=BigInt(o)))returnNaN;if(1n===o)returnBigInt(0);if(r=u(r,o),(i=BigInt(i))<0n)returne(n(r,t(i),o),o);letf=1n;for(;i>0;)i%2n===1n&&(f=f*r%o),i/=2n,r=r**2n%o;returnf},n.toZn=u,n}({});