const_ZERO=BigInt(0),_ONE=BigInt(1),_TWO=BigInt(2);functionabs(b){returnb=BigInt(b),b>=_ZERO?b:-b}functionbitLength(b){if(b=BigInt(b),b===_ONE)return1;letc=1;doc++;while((b>>=_ONE)>_ONE);returnc}functioneGcd(c,d){if(c=BigInt(c),d=BigInt(d),c<=_ZERO|d<=_ZERO)returnNaN;lete=_ZERO,f=_ONE,g=_ONE,h=_ZERO;for(;c!==_ZERO;){leta=d/c,b=d%c,i=e-g*a,j=f-h*a;d=c,c=b,e=g,f=h,g=i,h=j}return{b:d,x:e,y:f}}functiongcd(c,d){if(c=abs(c),d=abs(d),c===_ZERO)returnd;if(d===_ZERO)returnc;lete=_ZERO;for(;!((c|d)&_ONE);)c>>=_ONE,d>>=_ONE,e++;for(;!(c&_ONE);)c>>=_ONE;do{for(;!(d&_ONE);)d>>=_ONE;if(c>d){leta=c;c=d,d=a}d-=c}while(d);returnc<<e}asyncfunctionisProbablyPrime(a,b=16){return"number"==typeofa&&(a=BigInt(a)),newPromise((c,d)=>{conste=newWorker(_isProbablyPrimeWorkerUrl());e.onmessage=a=>{e.terminate(),c(a.data.isPrime)},e.onmessageerror=a=>{d(a)},e.postMessage({rnd:a,iterations:b,id:0})})}functionlcm(c,d){returnc=BigInt(c),d=BigInt(d),c===_ZERO&&d===_ZERO?_ZERO:abs(c*d)/gcd(c,d)}functionmax(c,d){returnc=BigInt(c),d=BigInt(d),c>=d?c:d}functionmin(c,d){returnc=BigInt(c),d=BigInt(d),c>=d?d:c}functionmodInv(b,a){if(b==_ZERO|a<=_ZERO)returnNaN;letc=eGcd(toZn(b,a),a);returnc.b===_ONE?toZn(c.x,a):NaN}functionmodPow(a,c,d){if(d=BigInt(d),d===_ZERO)returnNaN;if(d===_ONE)return_ZERO;if(a=toZn(a,d),c=BigInt(c),c<_ZERO)returnmodInv(modPow(a,abs(c),d),d);letf=_ONE;for(;0<c;)c%_TWO===_ONE&&(f=f*a%d),c/=_TWO,a=a**_TWO%d;returnf}functionprime(a,b=16,c=!1){if(1>a)thrownewRangeError(`bitLength MUST be > 0 and it is ${a}`);if(c){letd=_ZERO;dod=fromBuffer(randBytesSync(a/8,!0));while(!_isProbablyPrime(d,b));returnc?d:newPromise(a=>{a(d)})}returnnewPromise(c=>{letd=[];conste=(e,f)=>{if(e.isPrime){for(leta=0;a<d.length;a++)d[a].terminate();for(;d.length;)d.pop();c(e.value)}else{letc=randBits(a,!0),d=fromBuffer(c);try{f.postMessage({rnd:d,iterations:b,id:e.id})}catch(a){}}};{leta=_isProbablyPrimeWorkerUrl();for(letb,c=0;c<self.navigator.hardwareConcurrency;c++)b=newWorker(a),b.onmessage=a=>e(a.data,b),d.push(b)}for(lete=0;e<d.length;e++){letc=randBits(a,!0),f=fromBuffer(c);d[e].postMessage({rnd:f,iterations:b,id:e})}})}functionrandBetween(a,b=_ONE){if(a<=b)thrownewError("max must be > min");constc=a-b;letd,e=bitLength(c);do{leta=randBits(e);d=fromBuffer(a)}while(d>c);returnd+b}functionrandBits(a,b=!1){varc=Math.ceil;if(1>a)thrownewRangeError(`bitLength MUST be > 0 and it is ${a}`);constd=c(a/8);lete=randBytesSync(d,!1);if(e[0]&=2**(a%8)-1,b){letb=a%8?2**(a%8-1):128;e[0]|=b}returne}functionrandBytes(a,b=!1){if(1>a)thrownewRangeError(`byteLength MUST be > 0 and it is ${a}`);letc;returnnewPromise(function(d){c=newUint8Array(a),self.crypto.getRandomValues(c),b&&(c[0]|=128),d(c)})}functionrandBytesSync(a,b=!1){if(1>a)thrownewRangeError(`byteLength MUST be > 0 and it is ${a}`);letc;returnc=newUint8Array(a),self.crypto.getRandomValues(c),b&&(c[0]|=128),c}functiontoZn(b,c){return(c=BigInt(c),0>=c)?NaN:(b=BigInt(b)%c,0>b?b+c:b)}functionfromBuffer(a){letb=_ZERO;for(letcofa.values()){leta=BigInt(c);b=(b<<BigInt(8))+a}returnb}function_isProbablyPrimeWorkerUrl(){leta=`'use strict';const _ZERO = BigInt(0);const _ONE = BigInt(1);const _TWO = BigInt(2);const eGcd = ${eGcd.toString()};const modInv = ${modInv.toString()};const modPow = ${modPow.toString()};const toZn = ${toZn.toString()};const randBits = ${randBits.toString()};const randBytesSync = ${randBytesSync.toString()};const randBetween = ${randBetween.toString()};const isProbablyPrime = ${_isProbablyPrime.toString()};${bitLength.toString()}${fromBuffer.toString()}`;returna+=`onmessage = ${asyncfunction(a){constb=awaitisProbablyPrime(a.data.rnd,a.data.iterations);postMessage({isPrime:b,value:a.data.rnd,id:a.data.id})}.toString()};`,_workerUrl(a)}function_workerUrl(a){a=`(() => {${a}})()`;constb=newBlob([a],{type:"text/javascript"});returnwindow.URL.createObjectURL(b)}function_isProbablyPrime(c,b=16){if(c===_TWO)return!0;if((c&_ONE)===_ZERO||c===_ONE)return!1;conste=[3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,