-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfidola.min.js
22 lines (20 loc) · 37 KB
/
fidola.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/(function(){var e=function(t,n){var r=e.resolve(t,n||"/"),i=e.modules[r];if(!i)throw new Error("Failed to resolve module "+t+", tried "+r);var s=e.cache[r],o=s?s.exports:i();return o};e.paths=[],e.modules={},e.cache={},e.extensions=[".js",".coffee",".json"],e._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},e.resolve=function(){return function(t,n){function u(t){t=r.normalize(t);if(e.modules[t])return t;for(var n=0;n<e.extensions.length;n++){var i=e.extensions[n];if(e.modules[t+i])return t+i}}function a(t){t=t.replace(/\/+$/,"");var n=r.normalize(t+"/package.json");if(e.modules[n]){var i=e.modules[n](),s=i.browserify;if(typeof s=="object"&&s.main){var o=u(r.resolve(t,s.main));if(o)return o}else if(typeof s=="string"){var o=u(r.resolve(t,s));if(o)return o}else if(i.main){var o=u(r.resolve(t,i.main));if(o)return o}}return u(t+"/index")}function f(e,t){var n=l(t);for(var r=0;r<n.length;r++){var i=n[r],s=u(i+"/"+e);if(s)return s;var o=a(i+"/"+e);if(o)return o}var s=u(e);if(s)return s}function l(e){var t;e==="/"?t=[""]:t=r.normalize(e).split("/");var n=[];for(var i=t.length-1;i>=0;i--){if(t[i]==="node_modules")continue;var s=t.slice(0,i+1).join("/")+"/node_modules";n.push(s)}return n}n||(n="/");if(e._core[t])return t;var r=e.modules.path();n=r.resolve("/",n);var i=n||"/";if(t.match(/^(?:\.\.?\/|\/)/)){var s=u(r.resolve(i,t))||a(r.resolve(i,t));if(s)return s}var o=f(t,i);if(o)return o;throw new Error("Cannot find module '"+t+"'")}}(),e.alias=function(t,n){var r=e.modules.path(),i=null;try{i=e.resolve(t+"/package.json","/")}catch(s){i=e.resolve(t,"/")}var o=r.dirname(i),u=(Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t})(e.modules);for(var a=0;a<u.length;a++){var f=u[a];if(f.slice(0,o.length+1)===o+"/"){var l=f.slice(o.length);e.modules[n+l]=e.modules[o+l]}else f===o&&(e.modules[n]=e.modules[o])}},function(){var t={},n=typeof window!="undefined"?window:{},r=!1;e.define=function(i,s){!r&&e.modules.__browserify_process&&(t=e.modules.__browserify_process(),r=!0);var o=e._core[i]?"":e.modules.path().dirname(i),u=function(t){var n=e(t,o),r=e.cache[e.resolve(t,o)];return r&&r.parent===null&&(r.parent=a),n};u.resolve=function(t){return e.resolve(t,o)},u.modules=e.modules,u.define=e.define,u.cache=e.cache;var a={id:i,filename:i,exports:{},loaded:!1,parent:null};e.modules[i]=function(){return e.cache[i]=a,s.call(a.exports,u,a,a.exports,o,i,t,n),a.loaded=!0,a.exports}}}(),e.define("path",function(e,t,n,r,i,s,o){function u(e,t){var n=[];for(var r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}function a(e,t){var n=0;for(var r=e.length;r>=0;r--){var i=e[r];i=="."?e.splice(r,1):i===".."?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}var f=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){var e="",t=!1;for(var n=arguments.length;n>=-1&&!t;n--){var r=n>=0?arguments[n]:s.cwd();if(typeof r!="string"||!r)continue;e=r+"/"+e,t=r.charAt(0)==="/"}return e=a(u(e.split("/"),function(e){return!!e}),!t).join("/"),(t?"/":"")+e||"."},n.normalize=function(e){var t=e.charAt(0)==="/",n=e.slice(-1)==="/";return e=a(u(e.split("/"),function(e){return!!e}),!t).join("/"),!e&&!t&&(e="."),e&&n&&(e+="/"),(t?"/":"")+e},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(u(e,function(e,t){return e&&typeof e=="string"}).join("/"))},n.dirname=function(e){var t=f.exec(e)[1]||"",n=!1;return t?t.length===1||n&&t.length<=3&&t.charAt(1)===":"?t:t.substring(0,t.length-1):"."},n.basename=function(e,t){var n=f.exec(e)[2]||"";return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return f.exec(e)[3]||""}}),e.define("__browserify_process",function(e,t,n,r,i,s,o){var s=t.exports={};s.nextTick=function(){var e=typeof window!="undefined"&&window.setImmediate,t=typeof window!="undefined"&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){if(e.source===window&&e.data==="browserify-tick"){e.stopPropagation();if(n.length>0){var t=n.shift();t()}}},!0),function(t){n.push(t),window.postMessage("browserify-tick","*")}}return function(t){setTimeout(t,0)}}(),s.title="browser",s.browser=!0,s.env={},s.argv=[],s.binding=function(t){if(t==="evals")return e("vm");throw new Error("No such module. (Possibly not yet loaded)")},function(){var t="/",n;s.cwd=function(){return t},s.chdir=function(r){n||(n=e("path")),t=n.resolve(r,t)}}()}),e.define("/fidola.js",function(e,t,n,r,i,s,o){function a(e,t){for(var n in t)e[n]=t[n]}var u=n,f=u.seq={};a(f,e("./sequence/BinarySearch")),a(f,e("./sequence/KMP")),a(f,e("./sequence/LCS")),a(f,e("./sequence/LCStr")),a(f,e("./sequence/LIS")),a(f,e("./sequence/Shuffle"));var l=u.ds={};a(l,e("./datastructure/BinaryHeap.js")),a(l,e("./datastructure/CartesianTree.js")),a(l,e("./datastructure/RedBlackTree.js")),a(l,e("./datastructure/BinarySearchTree.js")),a(l,e("./datastructure/LinkedList.js")),a(l,e("./datastructure/ImmutableArray.js"));var c=u.nt={};a(c,e("./numbertheory/Basics.js")),a(c,e("./numbertheory/PrimalityTest.js")),a(c,e("./numbertheory/FNTT.js")),a(c,e("./arithmatic/Unsigned.js")),a(c,e("./arithmatic/Integer.js"));var h=u.numeric={};a(h,e("./numeric/FastFourierTransform.js")),a(h,e("./numeric/CubicPolynomialSolver.js"))}),e.define("/sequence/BinarySearch.js",function(e,t,n,r,i,s,o){function u(e,t){var n=0,r=e.length;while(n+1<r){var i=n+r>>1,s=e[i];if(s===t)return i;s<t?n=i+1:r=i}return e[n]===t?n:-1}function a(e,t,n){var r=0,i=e.length;while(r+1<i){var s=r+i>>1,o=e[s],u=n(o,t);if(u===0)return s;u<0?r=s+1:i=s}return n(e[r],t)==0?r:-1}n.binarySearch=u,n.binarySearchWithCompare=a}),e.define("/sequence/KMP.js",function(e,t,n,r,i,s,o){function u(e,t){t||(t=function(e,t){return e===t});var n,r=2,i,s=e.length;if(s===0)return[];if(s===1)return[-1];r=0,n=[-1],i=-1;while(r<s){while(i>-1&&!t(e[r],e[i]))i=n[i];r+=1,i+=1,t(e[r],e[i])?n[r]=n[i]:n[r]=i}return n}function a(e,t,n,r){n||(n=function(e,t){return e===t});var i=0,s=0,o=e.length,a=t.length;if(o<a)return-1;if(a===0)return 0;if(o===a){for(i=0;i<o;i+=1)if(!n(e[i],t[i]))return-1;return 0}r=r||u(t,n);while(s<o){while(i>-1&&!n(e[s],t[i]))i=r[i];i+=1,s+=1;if(i>=a)return s-i}return-1}n.KMPPreProcess=u,n.KMP=a}),e.define("/sequence/LCS.js",function(e,t,n,r,i,s,o){function u(e,t,n){n||(n=function(e,t){return e===t});if(e.length>t.length){var r=u(t,e,function(e,t){return n(t,e)});return{indicesA:r.indicesB,indicesB:r.indicesA,length:r.length,result:r.result}}if(e.length===0)return{indicesA:[],indicesB:[],length:0,result:[]};var i,s=t.length,o,a=e.length,f=0,l=[],f,c,h,p=[],d;for(i=0;i<s;i+=1){d=t[i],f=l.length,p=l.slice(0);for(o=0,c=0,h=0;o<a;o+=1)if(n(e[o],d)){while(c<f&&l[c].indexA<o)c+=1;while(h<f&&p[h].indexA<o)h+=1;if(!p[h]||p[h].indexA>o)p[h]={indexA:o,indexB:i,length:l[c-1]?l[c-1].length+1:1,trackBack:l[c-1]||null};l[c]?o=l[c].indexA:o=a}l=p}var v=[],m=[],g=l.length,y=l[g-1],b=[];for(i=g-1;i>=0;i-=1)b[i]=e[v[i]=y.indexA],m[i]=y.indexB,y=y.trackBack;return{indicesA:v,indicesB:m,length:g,result:b}}n.LCS=u}),e.define("/sequence/LCStr.js",function(e,t,n,r,i,s,o){function u(e,t,n){n||(n=function(e,t){return e===t});if(e.length>t.length){var r=u(t,e,function(e,t){return n(t,e)});return{startA:r.startB,startB:r.startA,length:r.length,result:r.result}}if(e.length===0)return{startA:0,startB:0,length:0,result:[]};var i,s=t.length,o,a=e.length,f,l=0,c,h=[],p,d=0,v=-1,m=-1;for(i=0;i<s;i+=1){p=t[i],n(e[0],p)&&(h.push(0,1),d===0&&(d=1,v=0,m=i));for(o=1,f=0;o<a;o+=1)if(n(e[o],p)){while(f<l&&c[f]<o-1)f+=2;f<l&&c[f]===o-1?(h.push(o,c[f+1]+1),c[f+1]+1>d&&(d=c[f+1]+1,v=o,m=i),f+=2):(h.push(o,1),d===0&&(d=1,v=o,m=i))}c=h,h=[],l=c.length}return{startA:v-d+1,startB:m-d+1,length:d,result:e.slice(v-d+1,v+1)}}function a(e,t){return u(e.split(""),t.split(""),function(e,t){return e===t}).result.join("")}n.LCStr=n.longestCommonSubarrayDP=u,n.LCStrStr=n.longestCommonSubstringDP=a}),e.define("/sequence/LIS.js",function(e,t,n,r,i,s,o){function u(e){var t=[],n=[],r=[];if(e.length===0)return r;t[1]=0,n[0]=-1;for(var i=1;i<e.length;i++){var s=e[i];if(e[t[1]]>s)n[i]=-1,t[1]=i;else if(e[t[t.length-1]]<s)n[i]=t[t.length-1],t.push(i);else{for(var o=1,u=t.length-1,a=o+u>>1;u>o+1;a=o+u>>1)e[t[a]]<s?o=a:u=a;n[i]=t[o],t[u]=i}}for(var f=t.length-1,l=t[f];l>=0;f--,l=n[l])r[f-1]=e[l];return r}n.LIS=n.longestIncreasingSubsequence=u}),e.define("/sequence/Shuffle.js",function(e,t,n,r,i,s,o){function u(e,t){var n,r=e.length,i,s;t||(t=Math.random);for(n=r-2;n>0;n--){i=t()*(n+1)>>0;if(i>=n)continue;s=e[n],e[n]=e[i],e[i]=s}}n.shuffle=u}),e.define("/datastructure/BinaryHeap.js",function(e,t,n,r,i,s,o){function u(e,t){typeof t=="undefined"&&(t=function(e,t){return e<t}),this._lessTest=t;if(typeof e!="undefined"){this._arr=e.slice(0);var n=this._arr,r,i=n.length,s;for(r=i-1;r>=0;r--)this._down(r)}else this._arr=[]}var a=u.prototype;a._up=function(e){var t=this._arr,n=t[e],r=this._lessTest,i;do{i=e-1>>1;if(!r(n,t[i]))break;t[e]=t[i],e=i}while(e>0);t[e]=n},a._down=function(e){var t=this._arr,n=this._lessTest,r=t[e],i,s,o=t.length;do{i=e*2+1,s=e*2+2;if(s>=o){i<o&&n(t[i],r)&&(t[e]=t[i],e=i);break}if(n(t[i],t[s])){if(!n(t[i],r))break;t[e]=t[i],e=i}else{if(!n(t[s],r))break;t[e]=t[s],e=s}}while(!0);t[e]=r},a.push=function(e){var t=this._arr;if(arguments.length>1)for(var n=0;n<arguments.length;n++)t.push(arguments[n]),this._up(t.length-1);else t.length===0?t.push(e):(t.push(e),this._up(t.length-1))},a.peek=function(){return this._arr[0]},a.pop=function(){var e=this._arr,t=e[0];return e.length>1?(e[0]=e[e.length-1],e.length--,this._down(0)):e.length=0,t},a.remove=function(e){var t=this._arr,n=-1,r=t.length-1;if(r===-1)return!1;if(t[r]===e)return t.length--,!0;while(n++<r)if(t[n]===e)return t[n]=t[r],t.length--,this._down(n),!0;return!1},a.size=function(){return this._arr.length},n.BinaryHeap=u}),e.define("/datastructure/CartesianTree.js",function(e,t,n,r,i,s,o){function u(e,t){typeof t=="undefined"&&(t=function(e,t){return e<t}),this.lessTest=t,this.array=[],this.parent=[],this.left=[],this.right=[],this.root=-1;if(typeof e=="undefined")return;var n=e.length;if(n==0)return;for(var r=0;r<n;r++)this.push(e[r])}var a=u.prototype;a.push=function(e){var t=this.lessTest,n=this.array.length;if(n==0){this.array.push(e),this.parent.push(-1),this.left.push(-1),this.right.push(-1),this.root=0;return}var r=n-1,i=-1;while(r!=-1&&t(e,this.array[r]))i=r,r=this.parent[r];i===-1?(this.parent.push(n-1),this.right[n-1]=n,this.left.push(-1)):r==-1?(this.parent[i]=n,this.parent.push(-1),this.left.push(i),this.root=n):(this.parent[i]=n,this.parent.push(r),this.right[r]=n,this.left.push(i)),this.right.push(-1),this.array.push(e)},a.rangeMinimum=function(e,t){return this.array.length==0?null:e<0||t<=e||e>=this.array.length||t>this.array.length?null:this._rangeMinimum(this.root,e,t)},a._rangeMinimum=function(e,t,n){return e<t?this._rangeMinimum(this.right[e],t,n):e>=n?this._rangeMinimum(this.left[e],t,n):this.array[e]},a.size=function(){return this.array.length},n.CartesianTree=u}),e.define("/datastructure/RedBlackTree.js",function(e,t,n,r,i,s,o){function u(){this.root=null}RedBlackTreeNode=function(e){this.data=e},RedBlackTreeNode.prototype={parent:null,left:null,right:null,red:!0,count:1,data:null,leftMost:function(){var e=this;while(e.left)e=e.left;return e},rightMost:function(){var e=this;while(e.right)e=e.right;return e}},u.NODE_TYPE=RedBlackTreeNode,u.prototype={root:null,length:0,first:function(){return this.root&&this.root.leftMost()},last:function(){return this.root&&this.root.rightMost()},next:function(e){if(e.right)return e.right.leftMost();if(e.parent){var t=e;while(t.parent&&t.parent.left!==t)t=t.parent;return t.parent}return null},prev:function(e){if(e.left)return e.left.rightMost();if(e.parent){var t=e;while(t.parent&&t.parent.right!==t)t=t.parent;return t.parent}return null},iterate:function(e,t){this.root&&this._nodeIterate(this.root,e,t)},removeNode:function(e){e&&(e.left&&e.right&&this.swap(e,e.right.leftMost()),this._nodeRemoveLeftMost(e),this.length--)},swap:function(e,t){var n=[e.left,t.left,e.right,t.right,e.parent,t.parent],r=e.parent&&e.parent.left===e,i=t.parent&&t.parent.left===t,s=e.red,o=e.count;e.red=t.red,t.red=s,e.count=t.count,t.count=o;for(var u=0;u<6;u++)n[u]===e?n[u]=t:n[u]===t&&(n[u]=e);t.left=n[0],e.left=n[1],t.right=n[2],e.right=n[3],t.parent=n[4],e.parent=n[5],n[0]&&(n[0].parent=t),n[1]&&(n[1].parent=e),n[2]&&(n[2].parent=t),n[3]&&(n[3].parent=e),n[4]?r?n[4].left=t:n[4].right=t:this.root=t,n[5]?i?n[5].left=e:n[5].right=e:this.root=e},_nodeIsRed:function(e){return!!e&&!!e.red},_nodeSibling:function(e){return e&&e.parent?e==e.parent.left?e.parent.right:e.parent.left:null},_nodeColorFlip:function(e){e.red=!e.red,e.left.red=!e.left.red,e.right.red=!e.right.red},_nodeRotateLeft:function(e){var t=e.right;t.parent=e.parent,t.count=e.count,e.count-=t.right?t.right.count+1:1,e.parent?e.parent.left==e?e.parent.left=t:e.parent.right=t:this.root=t,e.right=t.left,e.right&&(e.right.parent=e),t.left=e,e.parent=t},_nodeRotateRight:function(e){var t=e.left;t.parent=e.parent,t.count=e.count,e.count-=t.left?t.left.count+1:1,e.parent?e.parent.right===e?e.parent.right=t:e.parent.left=t:this.root=t,e.left=t.right,e.left&&(e.left.parent=e),t.right=e,e.parent=t},prepend:function(e){return this.insertAfter(null,e)},append:function(e){return this.insertBefore(null,e)},insertBefore:function(e,t){if(this.length==0)return this.root=t,this.length=1,t.red=!1,t;if(!e)return this.insertAfter(this.last(),t);if(!e.left){e.left=t,t.parent=e;var n=e;while(n)n.count++,n=n.parent;return this._nodeInsertFixUp(t),t}return this.insertAfter(e.left&&e.left.rightMost(),t)},insertAfter:function(e,t){if(this.length==0)return this.root=t,this.length=1,t.red=!1,t;if(!e)return this.insertBefore(this.first(),t);if(!e.right){e.right=t,t.parent=e;var n=e;while(n)n.count++,n=n.parent;return this._nodeInsertFixUp(t),t}return this.insertBefore(e.right&&e.right.leftMost(),t)},_nodeInsertFixUp:function(e){if(!e.parent)e.red=!1;else if(e.parent.red){var t=e.parent,n=t.parent,r=n.left===t?n.right:n.left;if(this._nodeIsRed(r))return this._nodeColorFlip(n),this._nodeInsertFixUp(n);if(e===t.right&&t===n.left){n.left=e,e.parent=n;if(t.right=e.left)t.right.parent=t;e.count=t.count,t.count-=e.right?e.right.count+1:1,e.left=t,t.parent=e,t=e,e=e.left}else if(e===t.left&&t===n.right){n.right=e,e.parent=n;if(t.left=e.right)t.left.parent=t;e.count=t.count,t.count-=e.left?e.left.count+1:1,e.right=t,t.parent=e,t=e,e=e.right}t.red=!1,n.red=!0,e==t.left?this._nodeRotateRight(n):this._nodeRotateLeft(n)}return e},_nodeRemoveFixUp:function(e,t,n){if(t===null)return;this._nodeIsRed(n)&&(t.red=!0,n.red=!1,e===t.left?(this._nodeRotateLeft(t),n=t.right):(this._nodeRotateRight(t),n=t.left)),!this._nodeIsRed(n.left)&&!this._nodeIsRed(n.right)?(n.red=!0,this._nodeIsRed(t)?t.red=!1:this._nodeRemoveFixUp(t,t.parent,this._nodeSibling(t))):(e===t.left&&!this._nodeIsRed(n.right)&&this._nodeIsRed(n.left)?(n.red=!0,n.left.red=!1,this._nodeRotateRight(n),n=n.parent):e===t.right&&!this._nodeIsRed(n.left)&&this._nodeIsRed(n.right)&&(n.red=!0,n.right.red=!1,this._nodeRotateLeft(n),n=n.parent),n.red=t.red,t.red=!1,e===t.left?(this._nodeRotateLeft(t),n.right.red=!1):(this._nodeRotateRight(t),n.left.red=!1))},_nodeIterate:function(e,t,n){e.left&&this._nodeIterate(e.left,t,n),t.call(n||this,e.data,e),e.right&&this._nodeIterate(e.right,t,n)},_nodeRemoveLeftMost:function(e){var t=e.left||e.right,n=this._nodeSibling(e);t&&(t.parent=e.parent),e.parent?e.parent.left===e?e.parent.left=t:e.parent.right=t:this.root=t;var r=e.parent;while(r)r.count--,r=r.parent;e.red||(this._nodeIsRed(t)?t.red=!1:this._nodeRemoveFixUp(t,e.parent,n)),e.left=e.right=e.parent=null,e.red=!1}},n.RedBlackTreeNode=RedBlackTreeNode,n.RedBlackTree=u}),e.define("/datastructure/BinarySearchTree.js",function(e,t,n,r,i,s,o){var u=e("../fidola"),a=u.ds.RedBlackTree,f=a.NODE_TYPE,l=function(e){e&&(this.lessTest=e)},c=l.prototype=new a;c.lessTest=function(e,t){return e<t},c.search=function(e){return this._nodeSearch(this.root,e)},c.searchMaxSmallerThan=function(e){return this._nodeSearchMaxSmallerThan(this.root,e)},c.searchMinGreaterThan=function(e){return this._nodeSearchMinGreaterThan(this.root,e)},c._nodeSearch=function(e,t){var n=this.lessTest;while(e&&e.data!==t)n(t,e.data)?e=e.left:e=e.right;return e},c._nodeSearchMaxSmallerThan=function(e,t){var n=this.lessTest,r=null;while(e)n(e.data,t)?(r=e,e=e.right):e=e.left;return r},c._nodeSearchMinGreaterThan=function(e,t){var n=this.lessTest,r=null;while(e)n(t,e.data)?(r=e,e=e.left):e=e.right;return r},c.insert=function(e){return this.length===0?(this.length++,this.root=new f(e),this.root.red=!1,this.root):(this.length++,this._nodeInsert(this.root,e,this.lessTest))},c._nodeInsert=function(e,t,n){return n(t,e.data)?e.left?this._nodeInsert(e.left,t,n):this.insertBefore(e,new f(t)):e.right?this._nodeInsert(e.right,t,n):this.insertAfter(e,new f(t))},c.remove=function(e){this.length&&this.removeNode(this.search(e))},n.BinarySearchTree=l}),e.define("/datastructure/LinkedList.js",function(e,t,n,r,i,s,o){function u(e){this.data=e,this.next=this.prev=null}function a(){}u.prototype={data:null,prev:null,next:null},a.prototype={head:null,tail:null,length:0,push:function(e){if(this.head===null)return this.length++,this.head=this.tail=new u(e);var t=new u(e);return t.prev=this.tail,this.tail.next=t,this.tail=t,this.length++,t},pop:function(){var e=this.tail;return e===null?null:e===this.head?(this.head=this.tail=null,this.length--,e):(this.tail=e.prev,e.prev=null,this.tail.next=null,this.length--,e)},shift:function(){var e=this.head;return e===null?null:this.tail===e?(this.head=this.tail=null,this.length--,e):(this.head=e.next,e.next=null,this.head.prev=null,this.length--,e)},unshift:function(e){if(this.head===null)return this.length++,this.head=this.tail=new u(e);var t=new u(e);return t.next=this.head,this.head.prev=t,this.head=t,this.length++,t},forEach:function(e){for(var t=this.head,n=0;t;t=t.next,n++)e(t.data,n,t,this)},remove:function(e){e.prev?e.prev.next=e.next:(this.head=e.next,this.head&&(this.head.prev=null)),e.next?e.next.prev=e.prev:(this.tail=e.prev,this.tail&&(this.tail.next=null)),e.prev=e.next=null,this.length--}},n.LinkedList=a}),e.define("/datastructure/ImmutableArray.js",function(e,t,n,r,i,s,o){function u(e,t){var n=1;t instanceof u?n=t.length()+1:t=null,this.length=function(){return n},this.tail=function(){return t},this.head=function(){return e}}function a(e,t){return new u(e,t)}u.prototype={clone:function(){return this.foldRight(null,a)},concat:function(e){return this.foldRight(e,a)},get:function(e){return e==0?this.head():e<0||this.tail()===null?null:this.tail().get(e-1)},foldLeft:function(e,t){var n=this;while(n)e=t(e,n.head()),n=n.tail();return e},foldRight:function(e,t){var n=[],r=this;while(r)n.push(r.head()),r=r.tail();while(n.length){var i=n.pop();e=t(i,e)}return e},map:function(e){return this.foldRight(null,function(t,n){return new u(e(t),n)})},filter:function(e){return this.foldRight(null,function(t,n){return e(t)?new u(t,n):n})},toArray:function(){return this.foldLeft([],function(e,t){return e.push(t),e})}},n.ImmutableArray=u}),e.define("/numbertheory/Basics.js",function(e,t,n,r,i,s,o){function u(e,t){var n,r;e<0&&(e=-e),t<0&&(t=-t);if(e===0)return t;if(t===0)return e;if(e===t)return e;if(e<t)return u(t,e);r=0;while((e&1)===0&&(t&1)===0)r++,e>>=1,t>>=1;while((e&1)===0)e>>=1;while((t&1)===0)t>>=1;while(e&&t&&e!=t)if(e<t){n=e,e=t-e>>1,t=n;while((e&1)===0)e>>=1}else{n=t,t=e-t>>1,e=n;while((t&1)===0)t>>=1}return e<<r}function a(e,t){var n;if(e<0)return n=a(-e,t),[n[0],-n[1],n[2]];if(t<0)return n=a(e,-t),[n[0],n[1],-n[2]];if(e===0)return[t,0,1];if(t===0)return[e,1,0];if(e===t)return[e,0,1];var r=0,i=0;while((e&1)===0&&(t&1)===0)r++,e>>=1,t>>=1;if((t&1)==0)return n=a(t,e),[n[0]<<r,n[2],n[1]];while((e&1)==0)i++,e>>=1;n=f(e,t);while(i)n[1]&1&&(n[1]-=t,n[2]+=e),n[1]>>=1,i--;return[n[0]<<r,n[1],n[2]]}function f(e,t){var n=e,r=t,i=1,s=0,o=0,u=1,a;do{t<e&&(a=e,e=t,t=a,a=i,i=o,o=a,a=s,s=u,u=a),a=e,e=t-e,t=a,a=i,i=o-i,o=a,a=s,s=u-s,u=a;if(e==0)return[t,o,u];while((e&1)==0)e>>=1,i&1&&(i-=r,s+=n),i>>=1,s>>=1}while(1)}function l(e,t){if(e==0)return NaN;var n=a(e,t);return n[0]==1?(n[1]%t+t)%t:NaN}function c(e,t,n){e>>>=0,t>>>=0,n>>>=0,e%=n,t%=n;if(e===0)return 0;if(t===0)return 0;if(n<65536||2147483647/e>=t)return e*t%n;var r=0;for(var i=1;i<=t;i+=i)i&t&&(r+=e,r%=n),e+=e,e%=n;return r}function h(e,t,n){e|=0,t|=0,n|=0,e%=n;if(t<0)return e=l(e,n),isNaN(e)?NaN:h(e,-t,n);if(e==0)return 0;if(t==0)return 1;e%=n;var r=1;while(t)t&1&&(r=c(r,e,n)),e=c(e,e,n),t>>=1;return r}n.gcd=u,n.egcd=a,n.multInv=l,n.powerMod=h,n.multMod=c}),e.define("/numbertheory/PrimalityTest.js",function(e,t,n,r,i,s,o){function a(e,t,n,r){var i=u.nt.powerMod(e,n,r);if(i===1)return!0;for(var s=0;s<t;s++){if(i===r-1)return!0;i=u.nt.multMod(i,i,r)}return!1}function l(){f=new Uint32Array(82025),f[0]=2;var e=1,t=new Uint32Array(32768);for(var n=3;n<=1024;n+=2)if(0==(t[n>>5]&1<<(n&31))){f[e++]=n;for(var r=n*n|0,i=n+n;r<1048576;r+=i)t[r>>5]|=1<<(r&31)}for(;n<1048576;n+=2)0==(t[n>>5]&1<<(n&31))&&(f[e++]=n)}function c(e){e|=0;if(e<=0)return!1;f||l();if(e<1048576)return u.seq.binarySearch(f,e)!==-1;if((e&1)==0)return!1;var t=e-1>>1,n=1;while((t&1)===0)n++,t>>=1;return a(2,n,t,e)&&a(7,n,t,e)&&a(61,n,t,e)}var u=e("../fidola"),f=null;n.primeQ=c}),e.define("/numbertheory/FNTT.js",function(e,t,n,r,i,s,o){function a(e,t,n,r){var i=this.length=1<<e,s,o,a;this.root=n,this.mod=t,this.rootTable={},this.inverseRootTable={};for(var f=0;f<e;f++)this.rootTable[i>>f+1]=n,this.inverseRootTable[i>>f+1]=r,n*=n,n%=t,r*=r,r%=t;this.rootTable[1]=1,this.inverseRootTable[1]=1,this.reverseTable=u(i)}var u=e("../numeric/FastFourierTransform").GetBitReverseTable;a.reverseTable={},a.prototype.forward=function(e){var t=this.length,n,r,i=this.reverseTable,s;for(n=0;n<t;n++)r=i[n],r<n&&(s=e[n],e[n]=e[r],e[r]=s);return this.__fnttcore(e,this.rootTable),e},a.prototype.backward=function(e){var t=this.length,n,r,i=this.reverseTable,s;for(n=0;n<t;n++)r=i[n],r<n&&(s=e[n],e[n]=e[r],e[r]=s);this.__fnttcore(e,this.inverseRootTable);for(n=0;n<t;n++)e[n]*=253,e[n]%=this.mod;return e},a.prototype.__fnttcore=function(e,t){var n=this.length,r=this.mod,i,s,o,u,a,f;s=1;while(s<n){u=t[s],a=1;for(o=0;o<s;o++){for(i=o;i<n;i+=s<<1)f=a*e[i+s],e[i+s]=e[i]-f,e[i]+=f;a*=u,a%=r}s<<=1}for(i=0;i<n;i++)e[i]%=r,e[i]+=r,e[i]%=r},n.FastNumberTheoreticTransform=a}),e.define("/numeric/FastFourierTransform.js",function(e,t,n,r,i,s,o){function h(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e++,e}function p(e){if(c[e])return c[e];var t=p(e>>1),n,r=e>>1,i=new Int32Array(e);for(n=0;n<r;n++)i[n+r]=(i[n]=t[n]<<1)+1;return i}function d(e,t,n,r){var i,s,o,f,l,c,h,d,v,m,g,y,b,w,E,S=p(t),x=n<<1,T=r<<1;for(i=0;i<t;i++)w=S[i],w<i&&(E=e[i*T+x],e[i*T+x]=e[w*T+x],e[w*T+x]=E,E=e[i*T+1+x],e[i*T+1+x]=e[w*T+1+x],e[w*T+1+x]=E);s=1,o=0;while(s<t){l=a[o],c=u[o],h=1,d=0;for(f=0;f<s;f++){for(i=f;i<t;i+=s<<1)v=i*T+x,m=v+s*T,g=h*e[m]-d*e[m+1],y=h*e[m+1]+d*e[m],e[m]=e[v]-g,e[m+1]=e[v+1]-y,e[v]+=g,e[v+1]+=y;b=h,h=b*l-d*c,d=b*c+d*l}s<<=1,o++}}function v(e,t,n){var r=n<<1,i,s,o,u,a;d(e,n,0,1),d(t,n,0,1);for(i=0;i<r;i+=2)s=e[i],o=e[i+1],u=t[i],a=t[i+1],e[i]=(s*u-o*a)/n,e[i+1]=-(s*a+o*u)/n;d(e,n,0,1);for(i=1;i<r*2;i+=2)e[i]=-e[i]}function m(e,t,n,r){var i=h(t)*2,s=i*2,o=new f(s),u=new f(s),a,l,c,p,d=n*2,m=Math.PI/t,g;for(var y=0,b=0;y<t*2;y+=2,b++)a=e[y*r+d]||0,l=e[y*r+d+1]||0,g=b*b*m,c=Math.cos(g),p=Math.sin(g),o[y]=c*a+p*l,o[y+1]=c*l-p*a,u[y]=c,u[y+1]=p,y>0&&(u[s-y]=c,u[s-y+1]=p);v(o,new f(u),i);for(y=0;y<t*2;y+=2)a=o[y],l=o[y+1],e[y*r+d]=a*u[y]+l*u[y+1],e[y*r+d+1]=-a*u[y+1]+l*u[y]}function g(e,t,n,r){t===(t&-t)?d(e,t,n,r):m(e,t,n,r)}function y(e,t){return t=t||e.length>>1,g(e,t,0,1),e}function b(e,t){t=t||e.length>>1;var n,r=t<<1;for(n=0;n<r;n+=2)e[n]=e[n]/t,e[n+1]=-e[n+1]/t;g(e,t,0,1);for(n=0;n<r;n+=2)e[n+1]=-e[n+1];return e}function w(e,t,n){var r;for(r=0;r<n;r++)g(e,t,r*t,1);for(r=0;r<t;r++)g(e,n,r,t);return e}function E(e,t,n){var r,i=t*n,s=i*2;for(r=0;r<s;r+=2)e[r]=e[r]/i,e[r+1]=-e[r+1]/i;for(r=0;r<n;r++)g(e,t,r*t,1);for(r=0;r<t;r++)g(e,n,r,t);for(r=0;r<s;r+=2)e[r+1]=-e[r+1];return e}var u=[],a=[],f=Float64Array;for(var l=0;l<32;l++)u[l]=Math.sin(-Math.PI/(1<<l)),a[l]=Math.cos(Math.PI/(1<<l));var c={1:new Int32Array(1),2:new Int32Array([0,1]),4:new Int32Array([0,2,1,3])};n.GetBitReverseTable=p,n.fft=y,n.ifft=b,n.fft2d=w,n.ifft2d=E}),e.define("/arithmatic/Unsigned.js",function(e,t,n,r,i,s,o){function u(e){this.array=e||[]}function d(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e++,e}u.DIGITS="0123456789";var a=e("../numeric/FastFourierTransform.js"),f=a.fft,l=a.ifft,c=15,h=32767;u.from=function(e){return e instanceof u?e:typeof e=="number"?u.fromNumber(e):u.fromString(e.toString())},u.fromNumber=function(e){if(e<0)throw new Error("Failed to convert negative number to unsigned integer.");var t=[],n=0;while(e)t[n++]=e&h,e>>=c;return new u(t)},u.fromString=function(e){var t=new u,n=e.length;if(!e.match(/^[0-9]*$/))throw new Error("Malformed integer string.");for(var r=n%4;r<=n;r+=4)t._mult_assign_1(1e4),t._plus_assign_1(+e.substring(Math.max(0,r-4),r));return t.normalize(),t};var p=u.prototype;p.clone=function(){var e=new u;return e.array=this.array.slice(0),e},p.toString=function(){this.normalize();if(this.array.length===0)return"0";if(this.array.length===1)return this.array[0].toString();var e=this.getDigits(1e4),t,n,r,i,s=u.DIGITS;for(t=0,n=e.length-1;t<n;t++,n--)r=e[t],i=e[n],e[n]=s[r/1e3>>0]+s[r/100%10>>0]+s[r/10%10>>0]+s[r%10],e[t]=s[i/1e3>>0]+s[i/100%10>>0]+s[i/10%10>>0]+s[i%10];return t===n&&(r=e[t],e[t]=s[r/1e3>>0]+s[r/100%10>>0]+s[r/10%10>>0]+s[r%10]),e[0]=+e[0],e.join("")},p.getDigits=function(e){var t,n,r;if(e==h+1)return this.array.slice(0);if(e==32){t=this.array,n=[],n.length=t.length*3;for(i=0;i<t.length;i++)r=t[i],n[i*3]=r&31,n[i*3+1]=r>>5&31,n[i*3+2]=r>>10&31}else if(e==8){t=this.array,n=[],n.length=t.length*5;for(i=0;i<t.length;i++)r=t[i],n[i*5]=r&7,n[i*5+1]=r>>3&7,n[i*5+2]=r>>6&7,n[i*5+3]=r>>9&7,n[i*5+4]=r>>12&7}else{t=this.array.slice();if(t.length>80)return this._base_convert_huge(e);n=[];while(t.length>0){for(var i=t.length-1,s=0;i>=0;i--)t[i]+=s<<c,s=t[i]%e,t[i]/=e,t[i]>>=0;while(t.length>0&&t[t.length-1]===0)t.length--;n.push(s)}}while(n.length>0&&n[n.length-1]===0)n.length--;return n},p._base_convert_huge=function(e){var t=u.from(e),n=1;for(;;){var r=t.clone();r.sqrAssign();if(r.cmp(this)>0)break;t=r,n<<=1}var i=this.divMod(t),s=i[0].getDigits(e),o=i[1].getDigits(e);while(o.length<n)o[o.length]=0;return o.concat(s)},p.normalize=function(){var e=this.array,t=e.length,n=0;for(var r=0;r<t;r++)n+=e[r],e[r]=n&h,n>>=c;while(n)e[r++]=n&h,n>>=c;while(e.length>0&&e[e.length-1]===0)e.length--;return this},p._resize=function(e){var t=this.array,n=t.length;t.length=e;for(;n<e;n++)t[n]=0},p.isZero=function(){return this.array.length==0},p.isEven=function(){return this.isZero()||(this.array[0]&1)===0},p.isOdd=function(){return!this.isEven()},p.cmp=function(e){return this._cmp_offset_a(e.array,0)},p._cmp_offset_a=function(e,t){if(this.array.length+t!=e.length)return this.array.length+t>e.length?1:-1;for(var n=this.array.length-1;n>=0;n--)if(this.array[n]!=e[n+t])return this.array[n]>e[n+t]?1:-1;return 0},p.shiftLeftAssign=function(e){var t=this.array,n=t.length,r,i=0;e>=c&&(i=e/c>>0,e%=c),t[n-1]<<e>=1<<c&&(t[n++]=0),t.length+=i;for(r=n-1;r>0;r--)t[r+i]=(t[r]<<e|t[r-1]>>c-e)&h;t[i]=t[0]<<e&h;for(r=0;r<i;r++)t[r]=0;return this},p.plusAssign=function(e){return typeof e=="number"?this._plus_assign_1(e):this._plus_assign_bi(u.from(e))},p.plus=function(e){return this.clone().plusAssign(e)},p.minusAssign=function(e){return typeof e=="number"?this._minus_assign_1(e):this._minus_assign_bi(u.from(e))},p.minus=function(e){return this.clone().minusAssign(e)},p._plus_assign_bi=function(e){var t,n=0,r=this.array,i=r.length,s=e.array,o=s.length;if(i<o)while(i<o)r[i++]=0;for(t=0;t<o;t++)n+=r[t]+s[t],r[t]=n&h,n>>=c;while(n)t>=i&&(r[t]=0),r[t]+=n&h,n>>=c,t++;return this},p._plus_assign_1=function(e){var t=this.array,n=t.length;for(var r=0,i=e;i&&r<n;r++)i+=t[r],t[r]=i&h,i>>=c;while(i)t[r++]=i&h,i>>=c;return this},p._minus_assign_1=function(e){var t=this.array,n=0,r=-e;while(r)r+=t[n],t[n]=r&h,r>>=c;return this},p._minus_assign_bi=function(e){var t=this.array,n=e.array,r=n.length,i,s=0;for(i=0;i<r;i++)s+=t[i]-n[i],t[i]=s&h,s>>=c;while(s)s+=t[i],t[i]=s&h,s>>=c;while(t.length&&t[t.length-1]===0)t.length--;return this},p.multAssign=function(e){return this.array.length==0?this:typeof e=="number"?e==0?(this.array.length=0,this):this._mult_assign_1(e):this._mult_assign_bi(u.from(e))},p.mult=function(e){return this.clone().multAssign(e)},p.sqrAssign=function(){var e=d(this.array.length)<<1;return this.array.length*this.array.length>45*e*Math.log(e)?this._sqr_assign_huge():(this._mult_assign_bi(this),this)},p._mult_assign_bi=function(e){if(e.array.length==0||this.array.length==0)return this.array.length=0,this;if(e.array.length==1)return this._mult_assign_1(e.array[0]);var t=d(e.array.length+this.array.length);if(e.array.length*this.array.length>45*t*Math.log(t))return this._mult_assign_huge(e);var n=this.array.slice(0),r=n.length,i=e.array,s=i.length,o,u,a=r+s-1,f,l=[],p;l.length=a;for(o=0;o<a;o++)l[o]=0;for(o=0;o<r;o++){p=n[o];if(p>0){for(u=0,f=0;u<s;u++)f+=l[o+u]+p*i[u],l[o+u]=f&h,f>>=c;while(f)o+u>=l.length&&(l[o+u]=0),f+=l[o+u],l[o+u]=f&h,f>>=c}}return this.array=l,this.normalize(),this},p._mult_assign_1=function(e){e>>=0;var t=this.array,n=t.length;for(var r=0,i=0;r<n;r++)i+=t[r]*e,t[r]=i&h,i>>=c;while(i)t[r++]=i&h,i>>=c;return this},p._mult_assign_huge=function(e){if(e===this)return this._sqr_assign_huge();var t=this.array,n=e.array,r=d(t.length*3+n.length*3),i=r*2,s,o,u,a=new Float64Array(i),p=new Float64Array(i);a.set(t,0),p.set(n,0);for(v=t.length;v>=0;v--)a[v*6+5]=0,a[v*6+4]=a[v]>>10&31,a[v*6+3]=0,a[v*6+2]=a[v]>>5&31,a[v*6+1]=0,a[v*6]=a[v]&31;for(v=n.length;v>=0;v--)p[v*6+5]=0,p[v*6+4]=p[v]>>10&31,p[v*6+3]=0,p[v*6+2]=p[v]>>5&31,p[v*6+1]=0,p[v*6]=p[v]&31;f(a,r),f(p,r);var v,m;for(v=0;v<i;v+=2)m=a[v]*p[v]-a[v+1]*p[v+1],a[v+1]=a[v]*p[v+1]+a[v+1]*p[v],a[v]=m;l(a,r),t.length=0,s=0;for(v=0,o=0,u=i-6;v<u;o++,v+=6)s+=Math.round(a[v])+(Math.round(a[v+2])<<5)+(Math.round(a[v+4])<<10),t[o]=s&h,s>>=c;for(;v<i;o++,v+=6)s+=Math.round(a[v]),v+2<i&&(s+=Math.round(a[v+2])<<5,v+4<i&&(s+=Math.round(a[v+4])<<10)),t[o]=s&h,s>>=c;while(s)t[o++]=s&h,s>>=c;while(t.length&&t[t.length-1]===0)t.length--;return this},p._sqr_assign_huge=function(){var e=this.array,t=d(this.array.length*6),n,r,i=new Float64Array(t*2);for(s=0;s<e.length;s++)i[s*6]=e[s]&31,i[s*6+2]=e[s]>>5&31,i[s*6+4]=e[s]>>10&31;f(i,t);var s,o=i.length,u;for(s=0;s<o;s+=2)u=i[s]*i[s]-i[s+1]*i[s+1],i[s+1]*=2*i[s],i[s]=u;l(i,t),e.length=0;for(s=0,n=0,r=0;s<t;r++){n+=Math.round(i[s<<1]),e[r]=n&31,n>>=5,s++;if(s>=t)break;n+=Math.round(i[s<<1]),e[r]|=(n&31)<<5,n>>=5,s++;if(s>=t)break;n+=Math.round(i[s<<1]),e[r]|=(n&31)<<10,n>>=5,s++}while(n){e[r]=n&31,n>>=5,s++;if(n==0)break;e[r]|=(n&31)<<5,n>>=5,s++;if(n==0)break;e[r]|=(n&31)<<10,n>>=5,s++}while(e.length&&e[e.length-1]===0)e.length--;return this},p.divAssignMod=function(e){var t;if(typeof e=="number"){if(e===0)throw new Error("Divide by zero");if(e<=h)return this._divAssignMod_1(e)}e=u.from(e);if(e.isZero())throw new Error("Divide by zero");return t=this._divAssignMod_bi(e),t},p.divMod=function(e){var t=this.clone(),n=t.divAssignMod
(e);return[t,n]},p._divAssignMod_1=function(e){var t=this.array,n=t.length,r,i=0;for(r=n-1;r>=0;r--)i<<=c,i+=t[r],t[r]=i/e>>0,i-=t[r]*e;return u.fromNumber(i)},p._divAssignMod_bi=function(e){if(e.array.length===0)throw new Error("Divide by zero");if(e.array.length===1)return this._divAssignMod_1(e.array[0]);var t=this.array.slice(0),n=t.length,r=e.array,i=r.length,s,o=0,a=t[n-1],f,l,p,d,v,m;switch(this.cmp(e)){case-1:return s=this.clone(),this.array.length=0,s;case 0:return this.array.length=1,this.array[0]=1,new u}this.array.length=n-i+1,f=(r[i-1]<<c)+r[i-2];for(var g=n-i;g>=0;g--){s=t[i+g]||0,o=t[i+g-1],a=t[i+g-2],v=Math.floor(((s*32768+o)*32768+a)/f);if(v>0){l=e.clone(),l._mult_assign_1(v),l._resize(i+ +!!s);while(1==(m=l._cmp_offset_a(t,g))){v--;if(v==0)break;l._minus_assign_bi(e),l._resize(i+ +!!s)}}else l=new u;for(p=0,d=0;p<l.array.length;p++)d+=t[p+g]-l.array[p],t[p+g]=d&h,d>>=c;t.length>g+i&&t[g+i]==0&&t.length--;if(m==0)s=o=a=0;else while(-1==e._cmp_offset_a(t,g)){v++;for(p=0,d=0;p<i;p++)d+=t[p+g]-r[p],t[p+g]=d&h,d>>=c;d&&(d+=t[p+g],t[p+g]=d&h,d>>=c)}t.length>g+i&&t[g+i]==0&&t.length--,this.array[g]=v}return new u(t)},n.Unsigned=u}),e.define("/arithmatic/Integer.js",function(e,t,n,r,i,s,o){function a(e,t){if(e instanceof a){this.clamp=e.clamp.clone(),this.sign=e.sign;return}this.clamp=e instanceof u?e.clone():new u(e.slice()),this.sign=typeof t=="number"?t:1,this.clamp.isZero()&&(this.sign=1)}var u=e("./Unsigned").Unsigned,f=a.prototype;f.clamp=null,f.sign=0,f.clone=function(){return new a(this.clamp,this.sign)},f.isZero=function(){return this.clamp.isZero()},f.isEven=function(){return this.clamp.isEven()},f.isOdd=function(){return this.clamp.isOdd()},f.isPositive=function(){return this.sign>0&&!this.isZero()},f.isNegative=function(){return this.sign<0&&!this.isZero()},f.negation=function(){return new a(this.clamp.clone(),-this.sign)},f.shiftLeftAssign=function(e){return this.clamp.shiftLeftAssign(e),this},f.shiftLeft=function(e){return this.clone().shiftLeftAssign(e)},a.from=function(e){return e instanceof a?e:e instanceof u?new a(e,1):typeof e=="number"?a.fromNumber(e):a.fromString(e.toString())},a.fromNumber=function(e){return e<0?new a(u.fromNumber(-e),-1):new a(u.fromNumber(e),1)},a.fromString=function(e){var t=1;return e[0]=="-"&&(e=e.substring(1),t=-1),new a(u.fromString(e),t)},f.getDigits=function(e){return this.clamp.getDigits(e)},f.cmp=function(e){return e=a.from(e),this.isZero()?e.isZero()?0:-e.sign:e.isZero()?this.sign:this.sign!=e.sign?this.sign-e.sign>>1:this.sign*this.clamp.cmp(e.clamp)},f.plus=function(e){return e=a.from(e),this.sign==e.sign?new a(this.clamp.plus(e.clamp),this.sign):this.clamp.cmp(e.clamp)<0?new a(e.clamp.minus(this.clamp),e.sign):new a(this.clamp.minus(e.clamp),this.sign)},f.plusAssign=function(e){return e=this.plus(e),this.clamp=e.clamp,this.sign=e.sign,this},f.minus=function(e){return e=a.from(e),this.sign!=e.sign?new a(this.clamp.plus(e.clamp),this.sign):this.clamp.cmp(e.clamp)<0?new a(e.clamp.minus(this.clamp),-this.sign):new a(this.clamp.minus(e.clamp),this.sign)},f.minusAssign=function(e){return e=this.minus(e),this.clamp=e.clamp,this.sign=e.sign,this},f.mult=function(e){return e=a.from(e),new a(this.clamp.mult(e.clamp),this.sign*e.sign)},f.multAssign=function(e){return e=a.from(e),this.clamp.multAssign(e.clamp),this.sign*=e.sign,this},f.sqrAssign=function(){return this.sign=1,this.clamp.sqrAssign(),this},f.divAssignMod=function(e){var t=this.divMod(e);return this.clamp=t[0].clamp,this.sign=t[0].sign,t[1]},f.divMod=function(e){if(this.isZero())return[a.fromNumber(0),a.fromNumber(0)];e=a.from(e);var t=this.clamp.divMod(e.clamp);return this.sign===e.sign?[new a(t[0],1),new a(t[1],this.sign)]:t[1].isZero()?[new a(t[0],-1),new a(t[1],1)]:[(new a(t[0],-1)).minus(1),(new a(t[1],this.sign)).plus(e)]},f.toString=function(){return this.clamp.isZero()?"0":(this.sign==1?"":"-")+this.clamp.toString()},n.Integer=a}),e.define("/numeric/CubicPolynomialSolver.js",function(e,t,n,r,i,s,o){function a(e){return e>=0?Math.exp(Math.log(e)/3):-Math.exp(Math.log(-e)/3)}function f(e,t){var n;return e===0?(n=function(e){return t},n.solve=function(e){return[]}):(n=function(n){return e*n+t},n.solve=function(n){return[(n-t)/e]}),n}function l(e,t,n){if(e===0)return f(t,n);var r=function(r){return(e*r+t)*r+n},i=t*t-4*e*n,s=function(t){return i+4*e*t},o=1/e*.5,u=-o*t;return o=Math.abs(o),r.solve=function(e){var t=s(e);return t<0?[]:(t=Math.sqrt(t),[u-t*o,u+t*o])},r}function c(e,t,n,r){if(e===0)return l(t,n,r);var i=function(i){return((e*i+t)*i+n)*i+r},s=t/e/3,o=n/e,f=r/e,c=s*s,h=(s*o-f)*.5-s*c,p=c-o/3,d=p*p*p,v,m;return p===0?i.solve=function(t){return[-s+a(h*2+t/e)]}:(p>0&&(v=Math.sqrt(p),m=v*v*v,v+=v),i.solve=function(t){t/=e;var n=h+t*.5,r=n*n-d,i,o,f,l,c,p;return r>0?(r=Math.sqrt(r),[-s+a(n+r)+a(n-r)]):r===0?(c=a(n),p=-s-c,n>=0?[p,p,-s+2*c]:[-s+2*c,p,p]):(i=Math.acos(n/m)/3,o=v*Math.cos(i)-s,f=v*Math.cos(i+u)-s,l=v*Math.cos(i-u)-s,[f,l,o])}),i}var u=2.0943951023931953;n.linearFunction=f,n.quadraticFunction=l,n.cubicFunction=c}),e.define("/browser.js",function(e,t,n,r,i,s,o){o.fidola=e("./fidola.js")}),e("/browser.js")})();