var bigintModArith=function(n){"use strict";function t(n){return(n=BigInt(n))>=0n?n:-n}function r(n,t){if((n=BigInt(n))<=0n|(t=BigInt(t))<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,i=1n,e=1n,u=0n;for(;0n!==n;){const o=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}}function i(n,r){if(n=t(n),r=t(r),0n===n)return r;if(0n===r)return n;let i=0n;for(;!(1n&(n|r));)n>>=1n,r>>=1n,i++;for(;!(1n&n);)n>>=1n;do{for(;!(1n&r);)r>>=1n;if(n>r){const t=n;n=r,r=t}r-=n}while(r);return n<>=1n)>1n);return t},n.eGcd=r,n.gcd=i,n.lcm=function(n,r){return n=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=function n(r,i,o){if(0n===(o=BigInt(o)))return NaN;if(1n===o)return BigInt(0);if(r=u(r,o),(i=BigInt(i))<0n)return e(n(r,t(i),o),o);let f=1n;for(;i>0;)i%2n===1n&&(f=f*r%o),i/=2n,r=r**2n%o;return f},n.toZn=u,n}({});