Problem:
Score: 400 points

Problem Statement

We have N integers A_1, A_2, ..., A_N.

There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq K \leq \frac{N(N-1)}{2}

-10^9 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.

Sample Input 1

4 3
3 3 -4 -2

Sample Output 1

-6

There are six ways to form a pair. The products of those pairs are 9, -12, -6, -12, -6, 8.

Sorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The third number in this list is -6.

Sample Input 2

10 40
5 4 3 2 -1 0 0 0 0 0

Sample Output 2

6

Sample Input 3

30 413
-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

Sample Output 3

448283280358331064

Solution in JavaScript (node.js v5.12) (judge verdict: Wrong Answer)

/*!
 * path: atcoder/abc155/d
 * URL: https://github.com/koukimetal/procomvis/tree/master/src/contest/atcoder/abc155/d
 */!function(e){var r={};function n(t){if(r[t])return r[t].exports;var i=r[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)n.d(t,i,function(r){return e[r]}.bind(null,i));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){"use strict";var t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};r.__esModule=!0;var i=t(n(1)),o=n(2);i.default.readFile("/dev/stdin","utf8",(function(e,r){!function(e){var r=new o.Solver,n=r.parse(e),t=r.solve(n);r.print(t)}(r)}))},function(e,r){e.exports=require("fs")},function(e,r,n){"use strict";var t,i=this&&this.__extends||(t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])})(e,r)},function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};r.__esModule=!0;var s=n(3),f=n(4),l=u(n(5)),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.prototype.mul=function(e,r){var n=new l.default(e),t=new l.default(r);return n.multipliedBy(t)},r.prototype.solve=function(e){var r=e.N,n=e.K,t=e.A,i=new Array(r);t.sort((function(e,r){return Math.abs(e)-Math.abs(r)})),i[r-1]={pos:0,neg:0,zer:0};for(var u=r-2;u>=0;u--){var s=i[u+1];i[u]=o({},s),t[u+1]>0?i[u].pos++:t[u+1]<0?i[u].neg++:i[u].zer++}var f=new Array(r);for(u=0;u<r;u++)f[u]={pos:0,neg:0,zer:0},0===t[u]?f[u].zer=r-u-1:t[u]>0?(f[u].pos=i[u].pos,f[u].neg=i[u].neg):(f[u].pos=i[u].neg,f[u].neg=i[u].pos);var l=f.reduce((function(e,r){return e+r.neg}),0),c=f.reduce((function(e,r){return e+r.zer}),0);if(n<=l){var a=n;for(u=r-1;u>=0;u--)if(a<=f[u].neg){for(var h=t[u]<0?-1:1,p=r-1;p>u;p--)if(h*t[p]<0&&a--,0===a)return{answer:this.mul(t[p],t[u])}}else a-=f[u].neg}else{if(n<=l+c)return{answer:this.mul(0,1)};for(a=n-l-c,u=0;u<r;u++)if(a<=f[u].pos){for(h=t[u]<0?-1:1,p=u+1;p<r;p++)if(h*t[p]>0&&a--,0===a)return{answer:this.mul(t[p],t[u])}}else a-=f[u].pos}return{answer:this.mul(111,1)}},r.prototype.parse=function(e){for(var r=f.getSpaceIterator(e,(function(e){return parseInt(e)})),n=r.next().value,t=r.next().value,i=[],o=0;o<n;o++)i.push(r.next().value);return{N:n,K:t,A:i}},r.prototype.print=function(e){console.log(e.answer.toString())},r}(s.SolverBase);r.Solver=c},function(e,r,n){"use strict";r.__esModule=!0;var t=function(){};r.SolverBase=t},function(e,r,n){"use strict";var t=this&&this.__generator||function(e,r){var n,t,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,t&&(i=2&o[0]?t.return:o[0]?t.throw||((i=t.return)&&i.call(t),0):t.next)&&!(i=i.call(t,o[1])).done)return i;switch(t=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,t=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=(i=u.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=r.call(e,u)}catch(e){o=[6,e],t=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};r.__esModule=!0,r.getSpaceIterator=function(e,r){var n,i;return t(this,(function(t){switch(t.label){case 0:n=0,i=e.split(/\s+/).map((function(e){return r(e)})),t.label=1;case 1:return n<i.length?[4,i[n]]:[3,4];case 2:t.sent(),t.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}},function(e,r,n){"use strict";n.r(r),n.d(r,"BigNumber",(function(){return w}));var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,o=Math.floor,u="[BigNumber Error] ",s=u+"Number primitive has more than 15 significant digits: ",f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function l(e){var r=0|e;return e>0||e===r?r:r-1}function c(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(n=14-(r=e[t++]+"").length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function a(e,r){var n,t,i=e.c,o=r.c,u=e.s,s=r.s,f=e.e,l=r.e;if(!u||!s)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-s:u;if(u!=s)return u;if(n=u<0,t=f==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return f>l^n?1:-1;for(s=(f=i.length)<(l=o.length)?f:l,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^n?1:-1;return f==l?0:f>l^n?1:-1}function h(e,r,n,t){if(e<r||e>n||e!==o(e))throw Error(u+(t||"Argument")+("number"==typeof e?e<r||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function p(e){var r=e.c.length-1;return l(e.e/14)==r&&e.c[r]%2!=0}function g(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function d(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}var w=function e(r){var n,w,v,m,y,b,O,_,N,E=j.prototype={constructor:j,toString:null,valueOf:null},A=new j(1),S=20,x=4,P=-7,M=21,B=-1e7,D=1e7,R=!1,I=1,T=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz";function j(e,r){var n,i,u,f,l,c,a,p,g=this;if(!(g instanceof j))return new j(e,r);if(null==r){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>D?g.c=g.e=null:e.e<B?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((c="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,l=e;l>=10;l/=10,f++);return void(f>D?g.c=g.e=null:(g.e=f,g.c=[e]))}p=String(e)}else{if(!t.test(p=String(e)))return v(g,p,c);g.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(f=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(f<0&&(f=l),f+=+p.slice(l+1),p=p.substring(0,l)):f<0&&(f=p.length)}else{if(h(r,2,U.length,"Base"),10==r)return F(g=new j(e),S+g.e+1,x);if(p=String(e),c="number"==typeof e){if(0*e!=0)return v(g,p,c,r);if(g.s=1/e<0?(p=p.slice(1),-1):1,j.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else g.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(n=U.slice(0,r),f=l=0,a=p.length;l<a;l++)if(n.indexOf(i=p.charAt(l))<0){if("."==i){if(l>f){f=a;continue}}else if(!u&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){u=!0,l=-1,f=0;continue}return v(g,String(e),c,r)}c=!1,(f=(p=w(p,r,10,g.s)).indexOf("."))>-1?p=p.replace(".",""):f=p.length}for(l=0;48===p.charCodeAt(l);l++);for(a=p.length;48===p.charCodeAt(--a););if(p=p.slice(l,++a)){if(a-=l,c&&j.DEBUG&&a>15&&(e>9007199254740991||e!==o(e)))throw Error(s+g.s*e);if((f=f-l-1)>D)g.c=g.e=null;else if(f<B)g.c=[g.e=0];else{if(g.e=f,g.c=[],l=(f+1)%14,f<0&&(l+=14),l<a){for(l&&g.c.push(+p.slice(0,l)),a-=14;l<a;)g.c.push(+p.slice(l,l+=14));l=14-(p=p.slice(l)).length}else l-=a;for(;l--;p+="0");g.c.push(+p)}}else g.c=[g.e=0]}function C(e,r,n,t){var i,o,u,s,f;if(null==n?n=x:h(n,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==r)f=c(e.c),f=1==t||2==t&&(u<=P||u>=M)?g(f,u):d(f,u,"0");else if(o=(e=F(new j(e),r,n)).e,s=(f=c(e.c)).length,1==t||2==t&&(r<=o||o<=P)){for(;s<r;f+="0",s++);f=g(f,o)}else if(r-=u,f=d(f,o,"0"),o+1>s){if(--r>0)for(f+=".";r--;f+="0");}else if((r+=o-s)>0)for(o+1==s&&(f+=".");r--;f+="0");return e.s<0&&i?"-"+f:f}function k(e,r){for(var n,t=1,i=new j(e[0]);t<e.length;t++){if(!(n=new j(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function G(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,t++);return(n=t+14*n-1)>D?e.c=e.e=null:n<B?e.c=[e.e=0]:(e.e=n,e.c=r),e}function F(e,r,n,t){var u,s,l,c,a,h,p,g=e.c,d=f;if(g){e:{for(u=1,c=g[0];c>=10;c/=10,u++);if((s=r-u)<0)s+=14,l=r,p=(a=g[h=0])/d[u-l-1]%10|0;else if((h=i((s+1)/14))>=g.length){if(!t)break e;for(;g.length<=h;g.push(0));a=p=0,u=1,l=(s%=14)-14+1}else{for(a=c=g[h],u=1;c>=10;c/=10,u++);p=(l=(s%=14)-14+u)<0?0:a/d[u-l-1]%10|0}if(t=t||r<0||null!=g[h+1]||(l<0?a:a%d[u-l-1]),t=n<4?(p||t)&&(0==n||n==(e.s<0?3:2)):p>5||5==p&&(4==n||t||6==n&&(s>0?l>0?a/d[u-l]:0:g[h-1])%10&1||n==(e.s<0?8:7)),r<1||!g[0])return g.length=0,t?(r-=e.e+1,g[0]=d[(14-r%14)%14],e.e=-r||0):g[0]=e.e=0,e;if(0==s?(g.length=h,c=1,h--):(g.length=h+1,c=d[14-s],g[h]=l>0?o(a/d[u-l]%d[l])*c:0),t)for(;;){if(0==h){for(s=1,l=g[0];l>=10;l/=10,s++);for(l=g[0]+=c,c=1;l>=10;l/=10,c++);s!=c&&(e.e++,1e14==g[0]&&(g[0]=1));break}if(g[h]+=c,1e14!=g[h])break;g[h--]=0,c=1}for(s=g.length;0===g[--s];g.pop());}e.e>D?e.c=e.e=null:e.e<B&&(e.c=[e.e=0])}return e}function z(e){var r,n=e.e;return null===n?e.toString():(r=c(e.c),r=n<=P||n>=M?g(r,n):d(r,n,"0"),e.s<0?"-"+r:r)}return j.clone=e,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(h(n=e[r],0,1e9,r),S=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(h(n=e[r],0,8,r),x=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(h(n[0],-1e9,0,r),h(n[1],0,1e9,r),P=n[0],M=n[1]):(h(n,-1e9,1e9,r),P=-(M=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)h(n[0],-1e9,-1,r),h(n[1],1,1e9,r),B=n[0],D=n[1];else{if(h(n,-1e9,1e9,r),!n)throw Error(u+r+" cannot be zero: "+n);B=-(D=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(u+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw R=!n,Error(u+"crypto unavailable");R=n}else R=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(h(n=e[r],0,9,r),I=n),e.hasOwnProperty(r="POW_PRECISION")&&(h(n=e[r],0,1e9,r),T=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(u+r+" not an object: "+n);L=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(u+r+" invalid: "+n);U=n}}return{DECIMAL_PLACES:S,ROUNDING_MODE:x,EXPONENTIAL_AT:[P,M],RANGE:[B,D],CRYPTO:R,MODULO_MODE:I,POW_PRECISION:T,FORMAT:L,ALPHABET:U}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var r,n,t=e.c,i=e.e,s=e.s;e:if("[object Array]"=={}.toString.call(t)){if((1===s||-1===s)&&i>=-1e9&&i<=1e9&&i===o(i)){if(0===t[0]){if(0===i&&1===t.length)return!0;break e}if((r=(i+1)%14)<1&&(r+=14),String(t[0]).length==r){for(r=0;r<t.length;r++)if((n=t[r])<0||n>=1e14||n!==o(n))break e;if(0!==n)return!0}}}else if(null===t&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return k(arguments,E.lt)},j.minimum=j.min=function(){return k(arguments,E.gt)},j.random=(m=9007199254740992*Math.random()&2097151?function(){return o(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,s,l,c=0,a=[],p=new j(A);if(null==e?e=S:h(e,0,1e9),s=i(e/14),R)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));c<s;)(l=131072*r[c]+(r[c+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[c]=n[0],r[c+1]=n[1]):(a.push(l%1e14),c+=2);c=s/2}else{if(!crypto.randomBytes)throw R=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);c<s;)(l=281474976710656*(31&r[c])+1099511627776*r[c+1]+4294967296*r[c+2]+16777216*r[c+3]+(r[c+4]<<16)+(r[c+5]<<8)+r[c+6])>=9e15?crypto.randomBytes(7).copy(r,c):(a.push(l%1e14),c+=7);c=s/7}if(!R)for(;c<s;)(l=m())<9e15&&(a[c++]=l%1e14);for(e%=14,(s=a[--c])&&e&&(l=f[14-e],a[c]=o(s/l)*l);0===a[c];a.pop(),c--);if(c<0)a=[t=0];else{for(t=-1;0===a[0];a.splice(0,1),t-=14);for(c=1,l=a[0];l>=10;l/=10,c++);c<14&&(t-=14-c)}return p.e=t,p.c=a,p}),j.sum=function(){for(var e=1,r=arguments,n=new j(r[0]);e<r.length;)n=n.plus(r[e++]);return n},w=function(){function e(e,r,n,t){for(var i,o,u=[0],s=0,f=e.length;s<f;){for(o=u.length;o--;u[o]*=r);for(u[0]+=t.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>n-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n|0,u[i]%=n)}return u.reverse()}return function(r,t,i,o,u){var s,f,l,a,h,p,g,w,v=r.indexOf("."),m=S,y=x;for(v>=0&&(a=T,T=0,r=r.replace(".",""),p=(w=new j(t)).pow(r.length-v),T=a,w.c=e(d(c(p.c),p.e,"0"),10,i,"0123456789"),w.e=w.c.length),l=a=(g=e(r,t,i,u?(s=U,"0123456789"):(s="0123456789",U))).length;0==g[--a];g.pop());if(!g[0])return s.charAt(0);if(v<0?--l:(p.c=g,p.e=l,p.s=o,g=(p=n(p,w,m,y,i)).c,h=p.r,l=p.e),v=g[f=l+m+1],a=i/2,h=h||f<0||null!=g[f+1],h=y<4?(null!=v||h)&&(0==y||y==(p.s<0?3:2)):v>a||v==a&&(4==y||h||6==y&&1&g[f-1]||y==(p.s<0?8:7)),f<1||!g[0])r=h?d(s.charAt(1),-m,s.charAt(0)):s.charAt(0);else{if(g.length=f,h)for(--i;++g[--f]>i;)g[f]=0,f||(++l,g=[1].concat(g));for(a=g.length;!g[--a];);for(v=0,r="";v<=a;r+=s.charAt(g[v++]));r=d(r,l,s.charAt(0))}return r}}(),n=function(){function e(e,r,n){var t,i,o,u,s=0,f=e.length,l=r%1e7,c=r/1e7|0;for(e=e.slice();f--;)s=((i=l*(o=e[f]%1e7)+(t=c*o+(u=e[f]/1e7|0)*l)%1e7*1e7+s)/n|0)+(t/1e7|0)+c*u,e[f]=i%n;return s&&(e=[s].concat(e)),e}function r(e,r,n,t){var i,o;if(n!=t)o=n>t?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function n(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(t,i,u,s,f){var c,a,h,p,g,d,w,v,m,y,b,O,_,N,E,A,S,x=t.s==i.s?1:-1,P=t.c,M=i.c;if(!(P&&P[0]&&M&&M[0]))return new j(t.s&&i.s&&(P?!M||P[0]!=M[0]:M)?P&&0==P[0]||!M?0*x:x/0:NaN);for(m=(v=new j(x)).c=[],x=u+(a=t.e-i.e)+1,f||(f=1e14,a=l(t.e/14)-l(i.e/14),x=x/14|0),h=0;M[h]==(P[h]||0);h++);if(M[h]>(P[h]||0)&&a--,x<0)m.push(1),p=!0;else{for(N=P.length,A=M.length,h=0,x+=2,(g=o(f/(M[0]+1)))>1&&(M=e(M,g,f),P=e(P,g,f),A=M.length,N=P.length),_=A,b=(y=P.slice(0,A)).length;b<A;y[b++]=0);S=M.slice(),S=[0].concat(S),E=M[0],M[1]>=f/2&&E++;do{if(g=0,(c=r(M,y,A,b))<0){if(O=y[0],A!=b&&(O=O*f+(y[1]||0)),(g=o(O/E))>1)for(g>=f&&(g=f-1),w=(d=e(M,g,f)).length,b=y.length;1==r(d,y,w,b);)g--,n(d,A<w?S:M,w,f),w=d.length,c=1;else 0==g&&(c=g=1),w=(d=M.slice()).length;if(w<b&&(d=[0].concat(d)),n(y,d,b,f),b=y.length,-1==c)for(;r(M,y,A,b)<1;)g++,n(y,A<b?S:M,b,f),b=y.length}else 0===c&&(g++,y=[0]);m[h++]=g,y[0]?y[b++]=P[_]||0:(y=[P[_]],b=1)}while((_++<N||null!=y[0])&&x--);p=null!=y[0],m[0]||m.splice(0,1)}if(1e14==f){for(h=1,x=m[0];x>=10;x/=10,h++);F(v,u+(v.e=h+14*a-1)+1,s,p)}else v.e=a,v.r=+p;return v}}(),y=/^(-?)0([xbo])(?=\w[\w.]*$)/i,b=/^([^.]+)\.$/,O=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,N=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,r,n,t){var i,o=n?r:r.replace(N,"");if(_.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(y,(function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r})),t&&(i=t,o=o.replace(b,"$1").replace(O,"0.$1")),r!=o))return new j(o,i);if(j.DEBUG)throw Error(u+"Not a"+(t?" base "+t:"")+" number: "+r);e.s=null}e.c=e.e=null},E.absoluteValue=E.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},E.comparedTo=function(e,r){return a(this,new j(e,r))},E.decimalPlaces=E.dp=function(e,r){var n,t,i,o=this;if(null!=e)return h(e,0,1e9),null==r?r=x:h(r,0,8),F(new j(o),e+o.e+1,r);if(!(n=o.c))return null;if(t=14*((i=n.length-1)-l(this.e/14)),i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},E.dividedBy=E.div=function(e,r){return n(this,new j(e,r),S,x)},E.dividedToIntegerBy=E.idiv=function(e,r){return n(this,new j(e,r),0,1)},E.exponentiatedBy=E.pow=function(e,r){var n,t,s,f,l,c,a,h,g=this;if((e=new j(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+z(e));if(null!=r&&(r=new j(r)),l=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return h=new j(Math.pow(+z(g),l?2-p(e):+z(e))),r?h.mod(r):h;if(c=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new j(NaN);(t=!c&&g.isInteger()&&r.isInteger())&&(g=g.mod(r))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||l&&g.c[1]>=24e7:g.c[0]<8e13||l&&g.c[0]<=9999975e7)))return f=g.s<0&&p(e)?-0:0,g.e>-1&&(f=1/f),new j(c?1/f:f);T&&(f=i(T/14+2))}for(l?(n=new j(.5),c&&(e.s=1),a=p(e)):a=(s=Math.abs(+z(e)))%2,h=new j(A);;){if(a){if(!(h=h.times(g)).c)break;f?h.c.length>f&&(h.c.length=f):t&&(h=h.mod(r))}if(s){if(0===(s=o(s/2)))break;a=s%2}else if(F(e=e.times(n),e.e+1,1),e.e>14)a=p(e);else{if(0===(s=+z(e)))break;a=s%2}g=g.times(g),f?g.c&&g.c.length>f&&(g.c.length=f):t&&(g=g.mod(r))}return t?h:(c&&(h=A.div(h)),r?h.mod(r):f?F(h,T,x,void 0):h)},E.integerValue=function(e){var r=new j(this);return null==e?e=x:h(e,0,8),F(r,r.e+1,e)},E.isEqualTo=E.eq=function(e,r){return 0===a(this,new j(e,r))},E.isFinite=function(){return!!this.c},E.isGreaterThan=E.gt=function(e,r){return a(this,new j(e,r))>0},E.isGreaterThanOrEqualTo=E.gte=function(e,r){return 1===(r=a(this,new j(e,r)))||0===r},E.isInteger=function(){return!!this.c&&l(this.e/14)>this.c.length-2},E.isLessThan=E.lt=function(e,r){return a(this,new j(e,r))<0},E.isLessThanOrEqualTo=E.lte=function(e,r){return-1===(r=a(this,new j(e,r)))||0===r},E.isNaN=function(){return!this.s},E.isNegative=function(){return this.s<0},E.isPositive=function(){return this.s>0},E.isZero=function(){return!!this.c&&0==this.c[0]},E.minus=function(e,r){var n,t,i,o,u=this,s=u.s;if(r=(e=new j(e,r)).s,!s||!r)return new j(NaN);if(s!=r)return e.s=-r,u.plus(e);var f=u.e/14,c=e.e/14,a=u.c,h=e.c;if(!f||!c){if(!a||!h)return a?(e.s=-r,e):new j(h?u:NaN);if(!a[0]||!h[0])return h[0]?(e.s=-r,e):new j(a[0]?u:3==x?-0:0)}if(f=l(f),c=l(c),a=a.slice(),s=f-c){for((o=s<0)?(s=-s,i=a):(c=f,i=h),i.reverse(),r=s;r--;i.push(0));i.reverse()}else for(t=(o=(s=a.length)<(r=h.length))?s:r,s=r=0;r<t;r++)if(a[r]!=h[r]){o=a[r]<h[r];break}if(o&&(i=a,a=h,h=i,e.s=-e.s),(r=(t=h.length)-(n=a.length))>0)for(;r--;a[n++]=0);for(r=1e14-1;t>s;){if(a[--t]<h[t]){for(n=t;n&&!a[--n];a[n]=r);--a[n],a[t]+=1e14}a[t]-=h[t]}for(;0==a[0];a.splice(0,1),--c);return a[0]?G(e,a,c):(e.s=3==x?-1:1,e.c=[e.e=0],e)},E.modulo=E.mod=function(e,r){var t,i,o=this;return e=new j(e,r),!o.c||!e.s||e.c&&!e.c[0]?new j(NaN):!e.c||o.c&&!o.c[0]?new j(o):(9==I?(i=e.s,e.s=1,t=n(o,e,0,3),e.s=i,t.s*=i):t=n(o,e,0,I),(e=o.minus(t.times(e))).c[0]||1!=I||(e.s=o.s),e)},E.multipliedBy=E.times=function(e,r){var n,t,i,o,u,s,f,c,a,h,p,g,d,w=this,v=w.c,m=(e=new j(e,r)).c;if(!(v&&m&&v[0]&&m[0]))return!w.s||!e.s||v&&!v[0]&&!m||m&&!m[0]&&!v?e.c=e.e=e.s=null:(e.s*=w.s,v&&m?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=l(w.e/14)+l(e.e/14),e.s*=w.s,(f=v.length)<(h=m.length)&&(d=v,v=m,m=d,i=f,f=h,h=i),i=f+h,d=[];i--;d.push(0));for(1e14,1e7,i=h;--i>=0;){for(n=0,p=m[i]%1e7,g=m[i]/1e7|0,o=i+(u=f);o>i;)n=((c=p*(c=v[--u]%1e7)+(s=g*c+(a=v[u]/1e7|0)*p)%1e7*1e7+d[o]+n)/1e14|0)+(s/1e7|0)+g*a,d[o--]=c%1e14;d[o]=n}return n?++t:d.splice(0,1),G(e,d,t)},E.negated=function(){var e=new j(this);return e.s=-e.s||null,e},E.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new j(e,r)).s,!i||!r)return new j(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/14,u=e.e/14,s=t.c,f=e.c;if(!o||!u){if(!s||!f)return new j(i/0);if(!s[0]||!f[0])return f[0]?e:new j(s[0]?t:0*i)}if(o=l(o),u=l(u),s=s.slice(),i=o-u){for(i>0?(u=o,n=f):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for((i=s.length)-(r=f.length)<0&&(n=f,f=s,s=n,r=i),i=0;r;)i=(s[--r]=s[r]+f[r]+i)/1e14|0,s[r]=1e14===s[r]?0:s[r]%1e14;return i&&(s=[i].concat(s),++u),G(e,s,u)},E.precision=E.sd=function(e,r){var n,t,i,o=this;if(null!=e&&e!==!!e)return h(e,1,1e9),null==r?r=x:h(r,0,8),F(new j(o),e,r);if(!(n=o.c))return null;if(t=14*(i=n.length-1)+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];i>=10;i/=10,t++);}return e&&o.e+1>t&&(t=o.e+1),t},E.shiftedBy=function(e){return h(e,-9007199254740991,9007199254740991),this.times("1e"+e)},E.squareRoot=E.sqrt=function(){var e,r,t,i,o,u=this,s=u.c,f=u.s,a=u.e,h=S+4,p=new j("0.5");if(1!==f||!s||!s[0])return new j(!f||f<0&&(!s||s[0])?NaN:s?u:1/0);if(0==(f=Math.sqrt(+z(u)))||f==1/0?(((r=c(s)).length+a)%2==0&&(r+="0"),f=Math.sqrt(+r),a=l((a+1)/2)-(a<0||a%2),t=new j(r=f==1/0?"1e"+a:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+a)):t=new j(f+""),t.c[0])for((f=(a=t.e)+h)<3&&(f=0);;)if(o=t,t=p.times(o.plus(n(u,o,h,1))),c(o.c).slice(0,f)===(r=c(t.c)).slice(0,f)){if(t.e<a&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(F(t,t.e+S+2,1),e=!t.times(t).eq(u));break}if(!i&&(F(o,o.e+S+2,0),o.times(o).eq(u))){t=o;break}h+=4,f+=4,i=1}return F(t,t.e+S+1,x,e)},E.toExponential=function(e,r){return null!=e&&(h(e,0,1e9),e++),C(this,e,r,1)},E.toFixed=function(e,r){return null!=e&&(h(e,0,1e9),e=e+this.e+1),C(this,e,r)},E.toFormat=function(e,r,n){var t,i=this;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=L;else if("object"!=typeof n)throw Error(u+"Argument not an object: "+n);if(t=i.toFixed(e,r),i.c){var o,s=t.split("."),f=+n.groupSize,l=+n.secondaryGroupSize,c=n.groupSeparator||"",a=s[0],h=s[1],p=i.s<0,g=p?a.slice(1):a,d=g.length;if(l&&(o=f,f=l,l=o,d-=o),f>0&&d>0){for(o=d%f||f,a=g.substr(0,o);o<d;o+=f)a+=c+g.substr(o,f);l>0&&(a+=c+g.slice(o)),p&&(a="-"+a)}t=h?a+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):a}return(n.prefix||"")+t+(n.suffix||"")},E.toFraction=function(e){var r,t,i,o,s,l,a,h,p,g,d,w,v=this,m=v.c;if(null!=e&&(!(a=new j(e)).isInteger()&&(a.c||1!==a.s)||a.lt(A)))throw Error(u+"Argument "+(a.isInteger()?"out of range: ":"not an integer: ")+z(a));if(!m)return new j(v);for(r=new j(A),p=t=new j(A),i=h=new j(A),w=c(m),s=r.e=w.length-v.e-1,r.c[0]=f[(l=s%14)<0?14+l:l],e=!e||a.comparedTo(r)>0?s>0?r:p:a,l=D,D=1/0,a=new j(w),h.c[0]=0;g=n(a,r,0,1),1!=(o=t.plus(g.times(i))).comparedTo(e);)t=i,i=o,p=h.plus(g.times(o=p)),h=o,r=a.minus(g.times(o=r)),a=o;return o=n(e.minus(t),i,0,1),h=h.plus(o.times(p)),t=t.plus(o.times(i)),h.s=p.s=v.s,d=n(p,i,s*=2,x).minus(v).abs().comparedTo(n(h,t,s,x).minus(v).abs())<1?[p,i]:[h,t],D=l,d},E.toNumber=function(){return+z(this)},E.toPrecision=function(e,r){return null!=e&&h(e,1,1e9),C(this,e,r,2)},E.toString=function(e){var r,n=this,t=n.s,i=n.e;return null===i?t?(r="Infinity",t<0&&(r="-"+r)):r="NaN":(null==e?r=i<=P||i>=M?g(c(n.c),i):d(c(n.c),i,"0"):10===e?r=d(c((n=F(new j(n),S+i+1,x)).c),n.e,"0"):(h(e,2,U.length,"Base"),r=w(d(c(n.c),i,"0"),10,e,t,!0)),t<0&&n.c[0]&&(r="-"+r)),r},E.valueOf=E.toJSON=function(){return z(this)},E._isBigNumber=!0,E[Symbol.toStringTag]="BigNumber",E[Symbol.for("nodejs.util.inspect.custom")]=E.valueOf,null!=r&&j.set(r),j}();r.default=w}]);