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