data-structure-typed 1.37.9 → 1.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,7 @@
4
4
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
5
5
  * @license MIT License
6
6
  */
7
- import type { Comparator } from '../../types';
8
- import { DFSOrderPattern } from '../../types';
7
+ import type { Comparator, DFSOrderPattern } from '../../types';
9
8
  export declare class Heap<E> {
10
9
  protected nodes: E[];
11
10
  protected readonly comparator: Comparator<E>;
@@ -1 +1 @@
1
- {"version":3,"file":"heap.js","sourceRoot":"","sources":["../../../src/data-structures/heap/heap.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,MAAa,IAAI;IAIf,YAAY,UAAyB;QAH3B,UAAK,GAAQ,EAAE,CAAC;QAIxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,OAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,OAAU;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAO,CAAC;SAC9B;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK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CAAC,IAAK,CAAC;YAEtC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;YAC3B,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC;YAE1B,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC;YACnC,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC;SACrC;QAED,0BAA0B;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE;YACpG,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;SAC5B;QAED,kBAAkB;QAClB,IAAI,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC;QAE9B,iCAAiC;QACjC,WAAW,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF;AAnSD,sCAmSC"}
@@ -5,8 +5,3 @@ export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNo
5
5
  export type BSTOptions = BinaryTreeOptions & {
6
6
  comparator?: BSTComparator;
7
7
  };
8
- export declare enum CP {
9
- lt = "lt",
10
- eq = "eq",
11
- gt = "gt"
12
- }
@@ -1,10 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CP = void 0;
4
- var CP;
5
- (function (CP) {
6
- CP["lt"] = "lt";
7
- CP["eq"] = "eq";
8
- CP["gt"] = "gt";
9
- })(CP || (exports.CP = CP = {}));
10
3
  //# sourceMappingURL=bst.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bst.js","sourceRoot":"","sources":["../../../../src/types/data-structures/binary-tree/bst.ts"],"names":[],"mappings":";;;AAYA,IAAY,EAAoC;AAAhD,WAAY,EAAE;IAAE,eAAS,CAAA;IAAE,eAAS,CAAA;IAAE,eAAS,CAAA;AAAA,CAAC,EAApC,EAAE,kBAAF,EAAE,QAAkC"}
1
+ {"version":3,"file":"bst.js","sourceRoot":"","sources":["../../../../src/types/data-structures/binary-tree/bst.ts"],"names":[],"mappings":""}
@@ -2,3 +2,8 @@ export type Comparator<T> = (a: T, b: T) => number;
2
2
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
3
3
  export type MapCallback<N> = (node: N) => any;
4
4
  export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
5
+ export declare enum CP {
6
+ lt = "lt",
7
+ eq = "eq",
8
+ gt = "gt"
9
+ }
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CP = void 0;
4
+ var CP;
5
+ (function (CP) {
6
+ CP["lt"] = "lt";
7
+ CP["eq"] = "eq";
8
+ CP["gt"] = "gt";
9
+ })(CP || (exports.CP = CP = {}));
3
10
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":";;;AAQA,IAAY,EAAoC;AAAhD,WAAY,EAAE;IAAE,eAAS,CAAA;IAAE,eAAS,CAAA;IAAE,eAAS,CAAA;AAAA,CAAC,EAApC,EAAE,kBAAF,EAAE,QAAkC"}
@@ -4,8 +4,7 @@
4
4
  * @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
5
5
  * @license MIT License
6
6
  */
7
- import type { Comparator } from '../../types';
8
- import { DFSOrderPattern } from '../../types';
7
+ import type { Comparator, DFSOrderPattern } from '../../types';
9
8
  export declare class Heap<E> {
10
9
  protected nodes: E[];
11
10
  protected readonly comparator: Comparator<E>;
@@ -5,8 +5,3 @@ export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNo
5
5
  export type BSTOptions = BinaryTreeOptions & {
6
6
  comparator?: BSTComparator;
7
7
  };
8
- export declare enum CP {
9
- lt = "lt",
10
- eq = "eq",
11
- gt = "gt"
12
- }
@@ -1,6 +1 @@
1
- export var CP;
2
- (function (CP) {
3
- CP["lt"] = "lt";
4
- CP["eq"] = "eq";
5
- CP["gt"] = "gt";
6
- })(CP || (CP = {}));
1
+ export {};
@@ -2,3 +2,8 @@ export type Comparator<T> = (a: T, b: T) => number;
2
2
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
3
3
  export type MapCallback<N> = (node: N) => any;
4
4
  export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
5
+ export declare enum CP {
6
+ lt = "lt",
7
+ eq = "eq",
8
+ gt = "gt"
9
+ }
@@ -1 +1,6 @@
1
- export {};
1
+ export var CP;
2
+ (function (CP) {
3
+ CP["lt"] = "lt";
4
+ CP["eq"] = "eq";
5
+ CP["gt"] = "gt";
6
+ })(CP || (CP = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.37.9",
3
+ "version": "1.38.0",
4
4
  "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -34,7 +34,8 @@
34
34
  "changelog": "auto-changelog",
35
35
  "coverage:badge": "istanbul-badges-readme",
36
36
  "ci": "env && git fetch --tags && npm run lint && npm run build && npm run update:subs && npm run test && npm run changelog",
37
- "publish:subs": "sh scripts/publish_all_subs.sh",
37
+ "copy:to-subs": "sh scripts/copy_to_all_subs.sh",
38
+ "publish:subs": "npm run copy:to-subs && sh scripts/publish_all_subs.sh",
38
39
  "publish:docs": "sh scripts/publish_docs.sh",
39
40
  "publish:all": "npm run ci && npm publish && npm run publish:subs && npm run publish:docs"
40
41
  },
@@ -58,17 +59,17 @@
58
59
  "@typescript-eslint/eslint-plugin": "^6.7.4",
59
60
  "@typescript-eslint/parser": "^6.7.4",
60
61
  "auto-changelog": "^2.4.0",
61
- "avl-tree-typed": "^1.37.8",
62
+ "avl-tree-typed": "^1.37.9",
62
63
  "benchmark": "^2.1.4",
63
- "binary-tree-typed": "^1.37.8",
64
- "bst-typed": "^1.37.8",
64
+ "binary-tree-typed": "^1.37.9",
65
+ "bst-typed": "^1.37.9",
65
66
  "dependency-cruiser": "^14.1.0",
66
67
  "eslint": "^8.50.0",
67
68
  "eslint-config-prettier": "^9.0.0",
68
69
  "eslint-import-resolver-alias": "^1.1.2",
69
70
  "eslint-import-resolver-typescript": "^3.6.1",
70
71
  "eslint-plugin-import": "^2.28.1",
71
- "heap-typed": "^1.37.8",
72
+ "heap-typed": "^1.37.9",
72
73
  "istanbul-badges-readme": "^1.8.5",
73
74
  "jest": "^29.7.0",
74
75
  "prettier": "^3.0.3",
@@ -5,8 +5,7 @@
5
5
  * @license MIT License
6
6
  */
7
7
 
8
- import type {Comparator} from '../../types';
9
- import {DFSOrderPattern} from '../../types';
8
+ import type {Comparator, DFSOrderPattern} from '../../types';
10
9
 
11
10
  export class Heap<E> {
12
11
  protected nodes: E[] = [];
package/umd/bundle.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see bundle.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.dataStructureTyped=e():t.dataStructureTyped=e()}(self,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AVLTree:()=>rt,AVLTreeNode:()=>it,AbstractEdge:()=>O,AbstractGraph:()=>L,AbstractVertex:()=>N,ArrayDeque:()=>x,BST:()=>$,BSTNode:()=>Z,BinaryIndexedTree:()=>tt,BinaryTree:()=>X,BinaryTreeNode:()=>J,CP:()=>W,Character:()=>yt,CoordinateMap:()=>r,CoordinateSet:()=>n,Deque:()=>y,DirectedEdge:()=>F,DirectedGraph:()=>P,DirectedVertex:()=>I,DoublyLinkedList:()=>d,DoublyLinkedListNode:()=>c,FamilyPosition:()=>G,FibonacciHeap:()=>C,FibonacciHeapNode:()=>V,HashMap:()=>l,HashTable:()=>i,HashTableNode:()=>s,Heap:()=>z,IterationType:()=>K,LinkedListQueue:()=>p,MapEdge:()=>j,MapGraph:()=>U,MapVertex:()=>q,Matrix2D:()=>vt,MatrixNTI2D:()=>gt,MaxHeap:()=>ut,MaxPriorityQueue:()=>ft,MinHeap:()=>ct,MinPriorityQueue:()=>dt,Navigator:()=>mt,ObjectDeque:()=>m,PriorityQueue:()=>A,Queue:()=>v,RBColor:()=>Q,RBTree:()=>ht,RBTreeNode:()=>nt,SegmentTree:()=>st,SegmentTreeNode:()=>et,SinglyLinkedList:()=>u,SinglyLinkedListNode:()=>a,SkipList:()=>g,SkipListNode:()=>f,Stack:()=>_,THUNK_SYMBOL:()=>w,TopologicalProperty:()=>Y,TreeMap:()=>h,TreeMultiset:()=>lt,TreeMultisetNode:()=>ot,TreeNode:()=>at,TreeSet:()=>o,Trie:()=>bt,TrieNode:()=>xt,UndirectedEdge:()=>B,UndirectedGraph:()=>H,UndirectedVertex:()=>D,Vector2D:()=>_t,arrayRemove:()=>E,getMSB:()=>R,isThunk:()=>k,toThunk:()=>M,trampoline:()=>T,trampolineAsync:()=>S,uuidV4:()=>b});class s{constructor(t,e){this.key=t,this.val=e,this.next=null}}class i{get hashFn(){return this._hashFn}set hashFn(t){this._hashFn=t}get buckets(){return this._buckets}set buckets(t){this._buckets=t}get capacity(){return this._capacity}set capacity(t){this._capacity=t}constructor(t=i.DEFAULT_CAPACITY,e){this._hashFn=e||this._defaultHashFn,this._capacity=Math.max(t,i.DEFAULT_CAPACITY),this._size=0,this._buckets=new Array(this._capacity).fill(null)}_defaultHashFn(t){return("string"==typeof t?this._murmurStringHashFn(t):this._objectHash(t))%this._capacity}_multiplicativeStringHashFn(t){const e=String(t);let s=0;for(let t=0;t<e.length;t++)s=(.618033988749895*s+e.charCodeAt(t))%(1<<30);return Math.abs(s)}_murmurStringHashFn(t){const e=String(t);let s=0;for(let t=0;t<e.length;t++)s=1540483477*(s^e.charCodeAt(t)),s=668265261*(s^s>>>15),s^=s>>>15;return Math.abs(s)}_hash(t){return this.hashFn(t)}_stringHash(t){let e=0;for(let s=0;s<t.length;s++)e=31*e+t.charCodeAt(s)&4294967295;return e}_objectHash(t){return this._stringHash(JSON.stringify(t))}set(t,e){const r=this._hash(t),n=new s(t,e);if(this._buckets[r]){let s=this._buckets[r];for(;s;){if(s.key===t)return void(s.val=e);if(!s.next)break;s=s.next}s.next=n}else this._buckets[r]=n;this._size++,this._size/this._capacity>=i.LOAD_FACTOR&&this._expand()}get(t){const e=this._hash(t);let s=this._buckets[e];for(;s;){if(s.key===t)return s.val;s=s.next}}delete(t){const e=this._hash(t);let s=this._buckets[e],i=null;for(;s;){if(s.key===t)return i?i.next=s.next:this._buckets[e]=s.next,this._size--,void(s.next=null);i=s,s=s.next}}_expand(){const t=2*this._capacity,e=new Array(t).fill(null);for(const t of this._buckets){let i=t;for(;i;){const t=this._hash(i.key),r=new s(i.key,i.val);if(e[t]){let s=e[t];for(;s.next;)s=s.next;s.next=r}else e[t]=r;i=i.next}}this._buckets=e,this._capacity=t}get size(){return this._size}}i.DEFAULT_CAPACITY=16,i.LOAD_FACTOR=.75;class r extends Map{constructor(t){super(),this._joint="_",void 0!==t&&(this._joint=t)}get joint(){return this._joint}has(t){return super.has(t.join(this._joint))}set(t,e){return super.set(t.join(this._joint),e)}get(t){return super.get(t.join(this._joint))}delete(t){return super.delete(t.join(this._joint))}_setJoint(t){this._joint=t}}class n extends Set{constructor(t){super(),this._joint="_",void 0!==t&&(this._joint=t)}get joint(){return this._joint}has(t){return super.has(t.join(this._joint))}add(t){return super.add(t.join(this._joint))}delete(t){return super.delete(t.join(this._joint))}_setJoint(t){this._joint=t}}class h{}class o{}class l{get hashFn(){return this._hashFn}set hashFn(t){this._hashFn=t}get table(){return this._table}set table(t){this._table=t}get capacityMultiplier(){return this._capacityMultiplier}set capacityMultiplier(t){this._capacityMultiplier=t}get loadFactor(){return this._loadFactor}set loadFactor(t){this._loadFactor=t}get initialCapacity(){return this._initialCapacity}set initialCapacity(t){this._initialCapacity=t}get size(){return this._size}set size(t){this._size=t}constructor(t=16,e=.75,s){this._initialCapacity=t,this._loadFactor=e,this._capacityMultiplier=2,this._size=0,this._table=new Array(t),this._hashFn=s||(t=>{const e=String(t);let s=0;for(let t=0;t<e.length;t++)s+=e.charCodeAt(t);return s%this.table.length})}_hash(t){return this._hashFn(t)}resizeTable(t){const e=new Array(t);for(const s of this._table)if(s)for(const[i,r]of s){const s=this._hash(i)%t;e[s]||(e[s]=[]),e[s].push([i,r])}this._table=e}set(t,e){this.size/this.table.length>=this.loadFactor&&this.resizeTable(this.table.length*this.capacityMultiplier);const s=this._hash(t);this.table[s]||(this.table[s]=[]);for(let i=0;i<this.table[s].length;i++)if(this.table[s][i][0]===t)return void(this.table[s][i][1]=e);this.table[s].push([t,e]),this.size++}get(t){const e=this._hash(t);if(this.table[e])for(const[s,i]of this.table[e])if(s===t)return i}delete(t){const e=this._hash(t);if(this.table[e])for(let s=0;s<this.table[e].length;s++)if(this.table[e][s][0]===t)return this.table[e].splice(s,1),this.size--,void(this.size/this.table.length<this.loadFactor/this.capacityMultiplier&&this.resizeTable(this.table.length/this.capacityMultiplier))}*entries(){for(const t of this.table)if(t)for(const[e,s]of t)yield[e,s]}[Symbol.iterator](){return this.entries()}clear(){this.size=0,this.table=new Array(this.initialCapacity)}isEmpty(){return 0===this.size}}class a{constructor(t){this._val=t,this._next=null}get val(){return this._val}set val(t){this._val=t}get next(){return this._next}set next(t){this._next=t}}class u{constructor(){this._head=null,this._tail=null,this._length=0}get head(){return this._head}set head(t){this._head=t}get tail(){return this._tail}set tail(t){this._tail=t}get length(){return this._length}static fromArray(t){const e=new u;for(const s of t)e.push(s);return e}getLength(){return this._length}push(t){const e=new a(t);this.head?(this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),this._length++}pop(){if(!this.head)return;if(this.head===this.tail){const t=this.head.val;return this.head=null,this.tail=null,this._length--,t}let t=this.head;for(;t.next!==this.tail;)t=t.next;const e=this.tail.val;return t.next=null,this.tail=t,this._length--,e}shift(){if(!this.head)return;const t=this.head;return this.head=this.head.next,this._length--,t.val}unshift(t){const e=new a(t);this.head?(e.next=this.head,this.head=e):(this.head=e,this.tail=e),this._length++}getAt(t){if(t<0||t>=this.length)return;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e.val}getNodeAt(t){let e=this.head;for(let s=0;s<t;s++)e=e.next;return e}deleteAt(t){if(t<0||t>=this.length)return;if(0===t)return this.shift();if(t===this.length-1)return this.pop();const e=this.getNodeAt(t-1),s=e.next;return e.next=s.next,this._length--,s.val}delete(t){let e;e=t instanceof a?t.val:t;let s=this.head,i=null;for(;s;){if(s.val===e)return null===i?(this.head=s.next,s===this.tail&&(this.tail=null)):(i.next=s.next,s===this.tail&&(this.tail=i)),this._length--,!0;i=s,s=s.next}return!1}insertAt(t,e){if(t<0||t>this.length)return!1;if(0===t)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;const s=new a(e),i=this.getNodeAt(t-1);return s.next=i.next,i.next=s,this._length++,!0}isEmpty(){return 0===this.length}clear(){this._head=null,this._tail=null,this._length=0}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.val),e=e.next;return t}reverse(){if(!this.head||this.head===this.tail)return;let t=null,e=this.head,s=null;for(;e;)s=e.next,e.next=t,t=e,e=s;[this.head,this.tail]=[this.tail,this.head]}find(t){let e=this.head;for(;e;){if(t(e.val))return e.val;e=e.next}return null}indexOf(t){let e=0,s=this.head;for(;s;){if(s.val===t)return e;e++,s=s.next}return-1}findNode(t){let e=this.head;for(;e;){if(e.val===t)return e;e=e.next}return null}insertBefore(t,e){if(!this.head)return!1;let s;if(s=t instanceof a?t.val:t,this.head.val===s)return this.unshift(e),!0;let i=this.head;for(;i.next;){if(i.next.val===s){const t=new a(e);return t.next=i.next,i.next=t,this._length++,!0}i=i.next}return!1}insertAfter(t,e){let s;if(s=t instanceof a?t:this.findNode(t),s){const t=new a(e);return t.next=s.next,s.next=t,s===this.tail&&(this.tail=t),this._length++,!0}return!1}countOccurrences(t){let e=0,s=this.head;for(;s;)s.val===t&&e++,s=s.next;return e}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.val,t=t.next}}class c{constructor(t){this._val=t,this._next=null,this._prev=null}get val(){return this._val}set val(t){this._val=t}get next(){return this._next}set next(t){this._next=t}get prev(){return this._prev}set prev(t){this._prev=t}}class d{constructor(){this._head=null,this._tail=null,this._length=0}get head(){return this._head}set head(t){this._head=t}get tail(){return this._tail}set tail(t){this._tail=t}get length(){return this._length}static fromArray(t){const e=new d;for(const s of t)e.push(s);return e}push(t){const e=new c(t);this.head?(e.prev=this.tail,this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),this._length++}addLast(t){this.push(t)}pop(){if(!this.tail)return;const t=this.tail;return this.head===this.tail?(this.head=null,this.tail=null):(this.tail=t.prev,this.tail.next=null),this._length--,t.val}pollLast(){return this.pop()}shift(){if(!this.head)return;const t=this.head;return this.head===this.tail?(this.head=null,this.tail=null):(this.head=t.next,this.head.prev=null),this._length--,t.val}pollFirst(){return this.shift()}unshift(t){const e=new c(t);this.head?(e.next=this.head,this.head.prev=e,this.head=e):(this.head=e,this.tail=e),this._length++}addFirst(t){this.unshift(t)}peekFirst(){var t;return null===(t=this.head)||void 0===t?void 0:t.val}peekLast(){var t;return null===(t=this.tail)||void 0===t?void 0:t.val}get size(){return this.length}getAt(t){if(t<0||t>=this.length)return;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e.val}getNodeAt(t){if(t<0||t>=this.length)return null;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e}findNode(t){let e=this.head;for(;e;){if(e.val===t)return e;e=e.next}return null}insertAt(t,e){if(t<0||t>this.length)return!1;if(0===t)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;const s=new c(e),i=this.getNodeAt(t-1),r=i.next;return s.prev=i,s.next=r,i.next=s,r.prev=s,this._length++,!0}deleteAt(t){if(t<0||t>=this.length)return;if(0===t)return this.shift();if(t===this.length-1)return this.pop();const e=this.getNodeAt(t),s=e.prev,i=e.next;return s.next=i,i.prev=s,this._length--,e.val}delete(t){let e;if(e=t instanceof c?t:this.findNode(t),e){if(e===this.head)this.shift();else if(e===this.tail)this.pop();else{const t=e.prev,s=e.next;t.next=s,s.prev=t,this._length--}return!0}return!1}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.val),e=e.next;return t}isEmpty(){return 0===this.length}clear(){this._head=null,this._tail=null,this._length=0}find(t){let e=this.head;for(;e;){if(t(e.val))return e.val;e=e.next}return null}indexOf(t){let e=0,s=this.head;for(;s;){if(s.val===t)return e;e++,s=s.next}return-1}findLast(t){let e=this.tail;for(;e;){if(t(e.val))return e.val;e=e.prev}return null}toArrayReverse(){const t=[];let e=this.tail;for(;e;)t.push(e.val),e=e.prev;return t}reverse(){let t=this.head;for([this.head,this.tail]=[this.tail,this.head];t;){const e=t.next;[t.prev,t.next]=[t.next,t.prev],t=e}}forEach(t){let e=this.head,s=0;for(;e;)t(e.val,s),e=e.next,s++}map(t){const e=new d;let s=this.head;for(;s;)e.push(t(s.val)),s=s.next;return e}filter(t){const e=new d;let s=this.head;for(;s;)t(s.val)&&e.push(s.val),s=s.next;return e}reduce(t,e){let s=e,i=this.head;for(;i;)s=t(s,i.val),i=i.next;return s}insertAfter(t,e){let s;if(s=t instanceof c?t:this.findNode(t),s){const t=new c(e);return t.next=s.next,s.next&&(s.next.prev=t),t.prev=s,s.next=t,s===this.tail&&(this.tail=t),this._length++,!0}return!1}insertBefore(t,e){let s;if(s=t instanceof c?t:this.findNode(t),s){const t=new c(e);return t.prev=s.prev,s.prev&&(s.prev.next=t),t.next=s,s.prev=t,s===this.head&&(this.head=t),this._length++,!0}return!1}}class f{constructor(t,e,s){this.key=t,this.value=e,this.forward=new Array(s)}}class g{get probability(){return this._probability}set probability(t){this._probability=t}get maxLevel(){return this._maxLevel}set maxLevel(t){this._maxLevel=t}get level(){return this._level}set level(t){this._level=t}get head(){return this._head}set head(t){this._head=t}constructor(t=16,e=.5){this._head=new f(null,null,t),this._level=0,this._maxLevel=t,this._probability=e}randomLevel(){let t=1;for(;Math.random()<this.probability&&t<this.maxLevel;)t++;return t}add(t,e){const s=new f(t,e,this.randomLevel()),i=new Array(this.maxLevel).fill(this.head);let r=this.head;for(let e=this.level-1;e>=0;e--){for(;r.forward[e]&&r.forward[e].key<t;)r=r.forward[e];i[e]=r}for(let t=0;t<s.forward.length;t++)s.forward[t]=i[t].forward[t],i[t].forward[t]=s;null!==s.forward[0]&&(this.level=Math.max(this.level,s.forward.length))}get(t){let e=this.head;for(let s=this.level-1;s>=0;s--)for(;e.forward[s]&&e.forward[s].key<t;)e=e.forward[s];if(e=e.forward[0],e&&e.key===t)return e.value}delete(t){const e=new Array(this.maxLevel).fill(this.head);let s=this.head;for(let i=this.level-1;i>=0;i--){for(;s.forward[i]&&s.forward[i].key<t;)s=s.forward[i];e[i]=s}if(s=s.forward[0],s&&s.key===t){for(let t=0;t<this.level&&e[t].forward[t]===s;t++)e[t].forward[t]=s.forward[t];for(;this.level>0&&null===this.head.forward[this.level-1];)this.level--;return!0}return!1}}class _{constructor(t){this._elements=Array.isArray(t)?t:[]}static fromArray(t){return new _(t)}isEmpty(){return 0===this._elements.length}size(){return this._elements.length}peek(){return this.isEmpty()?null:this._elements[this._elements.length-1]}push(t){return this._elements.push(t),this}pop(){return this.isEmpty()?null:this._elements.pop()||null}toArray(){return this._elements.slice()}clear(){this._elements=[]}clone(){return new _(this._elements.slice())}}class p extends u{enqueue(t){this.push(t)}dequeue(){return this.shift()}peek(){var t;return null===(t=this.head)||void 0===t?void 0:t.val}}class v{constructor(t){this._nodes=t||[],this._offset=0}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get offset(){return this._offset}set offset(t){this._offset=t}get size(){return this.nodes.length-this.offset}static fromArray(t){return new v(t)}push(t){return this.nodes.push(t),this}shift(){if(0===this.size)return;const t=this.peek();return this.offset+=1,2*this.offset<this.nodes.length||(this.nodes=this.nodes.slice(this.offset),this.offset=0),t}peek(){return this.size>0?this.nodes[this.offset]:void 0}peekLast(){return this.size>0?this.nodes[this.nodes.length-1]:void 0}enqueue(t){this.push(t)}dequeue(){return this.shift()}getAt(t){return this.nodes[t]}isEmpty(){return 0===this.size}toArray(){return this.nodes.slice(this.offset)}clear(){this.nodes=[],this.offset=0}clone(){return new v(this.nodes.slice(this.offset))}*[Symbol.iterator](){for(const t of this.nodes)yield t}}class y extends d{}class m{constructor(t){this._nodes={},this._capacity=Number.MAX_SAFE_INTEGER,this._first=-1,this._last=-1,this._size=0,void 0!==t&&(this._capacity=t)}get nodes(){return this._nodes}get capacity(){return this._capacity}set capacity(t){this._capacity=t}get first(){return this._first}set first(t){this._first=t}get last(){return this._last}set last(t){this._last=t}get size(){return this._size}addFirst(t){if(0===this._size){const t=Math.floor(this._capacity/2);this._first=t,this._last=t}else this._first--;this._nodes[this._first]=t,this._size++}addLast(t){if(0===this._size){const t=Math.floor(this._capacity/2);this._first=t,this._last=t}else this._last++;this._nodes[this._last]=t,this._size++}pollFirst(){if(!this._size)return;const t=this.peekFirst();return delete this._nodes[this._first],this._first++,this._size--,t}peekFirst(){if(this._size)return this._nodes[this._first]}pollLast(){if(!this._size)return;const t=this.peekLast();return delete this._nodes[this._last],this._last--,this._size--,t}peekLast(){if(this._size)return this._nodes[this._last]}get(t){return this._nodes[this._first+t]||null}isEmpty(){return this._size<=0}_seNodes(t){this._nodes=t}_setSize(t){this._size=t}}class x{constructor(){this._nodes=[]}get size(){return this._nodes.length}addLast(t){return this._nodes.push(t)}pollLast(){var t;return null!==(t=this._nodes.pop())&&void 0!==t?t:null}pollFirst(){var t;return null!==(t=this._nodes.shift())&&void 0!==t?t:null}addFirst(t){return this._nodes.unshift(t)}peekFirst(){var t;return null!==(t=this._nodes[0])&&void 0!==t?t:null}peekLast(){var t;return null!==(t=this._nodes[this._nodes.length-1])&&void 0!==t?t:null}get(t){var e;return null!==(e=this._nodes[t])&&void 0!==e?e:null}set(t,e){return this._nodes[t]=e}insert(t,e){return this._nodes.splice(t,0,e)}delete(t){return this._nodes.splice(t,1)}isEmpty(){return 0===this._nodes.length}}const b=function(){return"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g,(function(t){const e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},E=function(t,e){let s=-1,i=t?t.length:0;const r=[];for(;++s<i;){const n=t[s];e(n,s,t)&&(r.push(n),Array.prototype.splice.call(t,s--,1),i--)}return r},w=Symbol("thunk"),k=t=>"function"==typeof t&&t.__THUNK__===w,M=t=>{const e=()=>t();return e.__THUNK__=w,e},T=t=>Object.assign(((...e)=>{let s=t(...e);for(;k(s)&&"function"==typeof s;)s=s();return s}),{cont:(...e)=>M((()=>t(...e)))}),S=t=>Object.assign(((...e)=>{return s=void 0,i=void 0,n=function*(){let s=yield t(...e);for(;k(s)&&"function"==typeof s;)s=yield s();return s},new((r=void 0)||(r=Promise))((function(t,e){function h(t){try{l(n.next(t))}catch(t){e(t)}}function o(t){try{l(n.throw(t))}catch(t){e(t)}}function l(e){var s;e.done?t(e.value):(s=e.value,s instanceof r?s:new r((function(t){t(s)}))).then(h,o)}l((n=n.apply(s,i||[])).next())}));var s,i,r,n}),{cont:(...e)=>M((()=>t(...e)))}),R=t=>t<=0?0:1<<31-Math.clz32(t);class z{constructor(t){this.nodes=[],this.comparator=t}add(t){return this.push(t)}push(t){return this.nodes.push(t),this.bubbleUp(this.nodes.length-1),this}poll(){if(0===this.nodes.length)return;if(1===this.nodes.length)return this.nodes.pop();const t=this.nodes[0];return this.nodes[0]=this.nodes.pop(),this.sinkDown(0),t}pop(){return this.poll()}bubbleUp(t){const e=this.nodes[t];for(;t>0;){const s=Math.floor((t-1)/2),i=this.nodes[s];if(!(this.comparator(e,i)<0))break;this.nodes[t]=i,this.nodes[s]=e,t=s}}sinkDown(t){const e=2*t+1,s=2*t+2,i=this.nodes.length;let r=t;if(e<i&&this.comparator(this.nodes[e],this.nodes[r])<0&&(r=e),s<i&&this.comparator(this.nodes[s],this.nodes[r])<0&&(r=s),r!==t){const e=this.nodes[t];this.nodes[t]=this.nodes[r],this.nodes[r]=e,this.sinkDown(r)}}fix(){for(let t=Math.floor(this.size/2);t>=0;t--)this.sinkDown(t)}peek(){if(0!==this.nodes.length)return this.nodes[0]}get size(){return this.nodes.length}get leaf(){var t;return null!==(t=this.nodes[this.size-1])&&void 0!==t?t:void 0}isEmpty(){return 0===this.size}clear(){this.nodes=[]}refill(t){this.nodes=t,this.fix()}has(t){return this.nodes.includes(t)}dfs(t){const e=[],s=i=>{i<this.size&&("in"===t?(s(2*i+1),e.push(this.nodes[i]),s(2*i+2)):"pre"===t?(e.push(this.nodes[i]),s(2*i+1),s(2*i+2)):"post"===t&&(s(2*i+1),s(2*i+2),e.push(this.nodes[i])))};return s(0),e}toArray(){return[...this.nodes]}getNodes(){return this.nodes}clone(){const t=new z(this.comparator);return t.nodes=[...this.nodes],t}sort(){const t=[],e=this.clone();for(;0!==e.size;){const s=e.poll();s&&t.push(s)}return t}static heapify(t,e){const s=new z(e);return s.nodes=[...t],s.fix(),s}}class V{constructor(t,e=0){this.element=t,this.degree=e,this.marked=!1}}class C{constructor(t){if(this.size=0,this.clear(),this.comparator=t||this.defaultComparator,"function"!=typeof this.comparator)throw new Error("FibonacciHeap constructor: given comparator should be a function.")}defaultComparator(t,e){return t<e?-1:t>e?1:0}clear(){this.root=void 0,this.min=void 0,this.size=0}createNode(t){return new V(t)}mergeWithRoot(t){this.root?(t.right=this.root.right,t.left=this.root,this.root.right.left=t,this.root.right=t):this.root=t}add(t){return this.push(t)}push(t){const e=this.createNode(t);return e.left=e,e.right=e,this.mergeWithRoot(e),(!this.min||this.comparator(e.element,this.min.element)<=0)&&(this.min=e),this.size++,this}peek(){return this.min?this.min.element:void 0}consumeLinkedList(t){const e=[];if(!t)return e;let s=t,i=!1;for(;s!==t||!i;)s===t&&(i=!0),s&&(e.push(s),s=s.right);return e}removeFromRoot(t){this.root===t&&(this.root=t.right),t.left&&(t.left.right=t.right),t.right&&(t.right.left=t.left)}mergeWithChild(t,e){t.child?(e.right=t.child.right,e.left=t.child,t.child.right.left=e,t.child.right=e):t.child=e}link(t,e){this.removeFromRoot(t),t.left=t,t.right=t,this.mergeWithChild(e,t),e.degree++,t.parent=e}consolidate(){const t=new Array(this.size),e=this.consumeLinkedList(this.root);let s,i,r,n;for(const h of e){for(s=h,r=s.degree;t[r];)i=t[r],this.comparator(s.element,i.element)>0&&(n=s,s=i,i=n),this.link(i,s),t[r]=void 0,r++;t[r]=s}for(let e=0;e<this.size;e++)t[e]&&this.comparator(t[e].element,this.min.element)<=0&&(this.min=t[e])}poll(){return this.pop()}pop(){if(0===this.size)return;const t=this.min;if(t.child){const e=this.consumeLinkedList(t.child);for(const t of e)this.mergeWithRoot(t),t.parent=void 0}return this.removeFromRoot(t),t===t.right?(this.min=void 0,this.root=void 0):(this.min=t.right,this.consolidate()),this.size--,t.element}merge(t){if(0!==t.size){if(this.root&&t.root){const e=this.root,s=t.root,i=e.right,r=s.left;e.right=s,s.left=e,i.left=r,r.right=i}(!this.min||t.min&&this.comparator(t.min.element,this.min.element)<0)&&(this.min=t.min),this.size+=t.size,t.clear()}}}class A extends z{constructor(t){super(t)}}class N{constructor(t,e){this._key=t,this._val=e}get key(){return this._key}set key(t){this._key=t}get val(){return this._val}set val(t){this._val=t}}class O{constructor(t,e){this._weight=void 0!==t?t:1,this._val=e,this._hashCode=b()}get val(){return this._val}set val(t){this._val=t}get weight(){return this._weight}set weight(t){this._weight=t}get hashCode(){return this._hashCode}_setHashCode(t){this._hashCode=t}}class L{constructor(){this._vertices=new Map}get vertices(){return this._vertices}getVertex(t){return this._vertices.get(t)||null}hasVertex(t){return this._vertices.has(this._getVertexKey(t))}addVertex(t,e){if(t instanceof N)return this._addVertexOnly(t);{const s=this.createVertex(t,e);return this._addVertexOnly(s)}}removeVertex(t){const e=this._getVertexKey(t);return this._vertices.delete(e)}removeAllVertices(t){const e=[];for(const s of t)e.push(this.removeVertex(s));return e.length>0}hasEdge(t,e){return!!this.getEdge(t,e)}addEdge(t,e,s,i){if(t instanceof O)return this._addEdgeOnly(t);if(e instanceof N||"string"==typeof e||"number"==typeof e){if(!this.hasVertex(t)||!this.hasVertex(e))return!1;t instanceof N&&(t=t.key),e instanceof N&&(e=e.key);const r=this.createEdge(t,e,s,i);return this._addEdgeOnly(r)}throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge")}setEdgeWeight(t,e,s){const i=this.getEdge(t,e);return!!i&&(i.weight=s,!0)}getAllPathsBetween(t,e){const s=[],i=this._getVertex(t),r=this._getVertex(e);if(!i||!r)return[];const n=(t,e,r,h)=>{r.set(t,!0),t===e&&s.push([i,...h]);const o=this.getNeighbors(t);for(const t of o)r.get(t)||(h.push(t),n(t,e,r,h),E(h,(e=>e===t)));r.set(t,!1)};return n(i,r,new Map,[]),s}getPathSumWeight(t){var e;let s=0;for(let i=0;i<t.length;i++)s+=(null===(e=this.getEdge(t[i],t[i+1]))||void 0===e?void 0:e.weight)||0;return s}getMinCostBetween(t,e,s){if(void 0===s&&(s=!1),s){const s=this.getAllPathsBetween(t,e);let i=1/0;for(const t of s)i=Math.min(this.getPathSumWeight(t),i);return i}{const s=this._getVertex(e),i=this._getVertex(t);if(!i||!s)return null;const r=new Map,n=new v([i]);r.set(i,!0);let h=0;for(;n.size>0;){for(let t=0;t<n.size;t++){const t=n.shift();if(t===s)return h;if(void 0!==t){const e=this.getNeighbors(t);for(const t of e)r.has(t)||(r.set(t,!0),n.push(t))}}h++}return null}}getMinPathBetween(t,e,s){if(void 0===s&&(s=!1),s){const s=this.getAllPathsBetween(t,e);let i=1/0,r=-1,n=0;for(const t of s){const e=this.getPathSumWeight(t);e<i&&(i=e,r=n),n++}return s[r]||null}{let s=[];const i=this._getVertex(t),r=this._getVertex(e);if(!i||!r)return[];const n=(t,e,r,h)=>{if(r.set(t,!0),t===e)return void(s=[i,...h]);const o=this.getNeighbors(t);for(const t of o)r.get(t)||(h.push(t),n(t,e,r,h),E(h,(e=>e===t)));r.set(t,!1)};return n(i,r,new Map,[]),s}}dijkstraWithoutHeap(t,e,s,i){void 0===s&&(s=!1),void 0===i&&(i=!1),void 0===e&&(e=null);let r=1/0,n=null,h=[];const o=[],l=this._vertices,a=new Map,u=new Set,c=new Map,d=this._getVertex(t),f=e?this._getVertex(e):null;if(!d)return null;for(const t of l){const e=t[1];e instanceof N&&a.set(e,1/0)}a.set(d,0),c.set(d,null);const g=()=>{let t=1/0,e=null;for(const[s,i]of a)u.has(s)||i<t&&(t=i,e=s);return e},_=t=>{for(const e of l){const s=e[1];if(s instanceof N){const i=[s];let r=c.get(s);for(;r;)i.push(r),r=c.get(r);const n=i.reverse();e[1]===t&&(h=n),o.push(n)}}};for(let t=1;t<l.size;t++){const t=g();if(t){if(u.add(t),f&&f===t)return s&&(r=a.get(f)||1/0),i&&_(f),{distMap:a,preMap:c,seen:u,paths:o,minDist:r,minPath:h};const e=this.getNeighbors(t);for(const s of e)if(!u.has(s)){const e=this.getEdge(t,s);if(e){const i=a.get(t),r=a.get(s);void 0!==i&&void 0!==r&&e.weight+i<r&&(a.set(s,e.weight+i),c.set(s,t))}}}}return s&&a.forEach(((t,e)=>{e!==d&&t<r&&(r=t,i&&(n=e))})),i&&_(n),{distMap:a,preMap:c,seen:u,paths:o,minDist:r,minPath:h}}dijkstra(t,e,s,i){var r;void 0===s&&(s=!1),void 0===i&&(i=!1),void 0===e&&(e=null);let n=1/0,h=null,o=[];const l=[],a=this._vertices,u=new Map,c=new Set,d=new Map,f=this._getVertex(t),g=e?this._getVertex(e):null;if(!f)return null;for(const t of a){const e=t[1];e instanceof N&&u.set(e,1/0)}const _=new A(((t,e)=>t.key-e.key));_.add({key:0,val:f}),u.set(f,0),d.set(f,null);const p=t=>{for(const e of a){const s=e[1];if(s instanceof N){const i=[s];let r=d.get(s);for(;r;)i.push(r),r=d.get(r);const n=i.reverse();e[1]===t&&(o=n),l.push(n)}}};for(;_.size>0;){const t=_.poll(),e=null==t?void 0:t.key,h=null==t?void 0:t.val;if(void 0!==e&&h){if(c.add(h),g&&g===h)return s&&(n=u.get(g)||1/0),i&&p(g),{distMap:u,preMap:d,seen:c,paths:l,minDist:n,minPath:o};const t=this.getNeighbors(h);for(const s of t)if(!c.has(s)){const t=null===(r=this.getEdge(h,s))||void 0===r?void 0:r.weight;if("number"==typeof t){const i=u.get(s);i&&e+t<i&&(_.add({key:e+t,val:s}),d.set(s,h),u.set(s,e+t))}}}}return s&&u.forEach(((t,e)=>{e!==f&&t<n&&(n=t,i&&(h=e))})),i&&p(h),{distMap:u,preMap:d,seen:c,paths:l,minDist:n,minPath:o}}bellmanFord(t,e,s,i){void 0===s&&(s=!1),void 0===i&&(i=!1);const r=this._getVertex(t),n=[],h=new Map,o=new Map;let l,a=1/0,u=[];if(e&&(l=!1),!r)return{hasNegativeCycle:l,distMap:h,preMap:o,paths:n,min:a,minPath:u};const c=this._vertices,d=c.size,f=this.edgeSet(),g=f.length;this._vertices.forEach((t=>{h.set(t,1/0)})),h.set(r,0);for(let t=1;t<d;++t)for(let t=0;t<g;++t){const e=this.getEndsOfEdge(f[t]);if(e){const[s,r]=e,n=f[t].weight,l=h.get(s),a=h.get(r);void 0!==l&&void 0!==a&&h.get(s)!==1/0&&l+n<a&&(h.set(r,l+n),i&&o.set(r,s))}}let _=null;if(s&&h.forEach(((t,e)=>{e!==r&&t<a&&(a=t,i&&(_=e))})),i)for(const t of c){const e=t[1];if(e instanceof N){const s=[e];let i=o.get(e);for(;void 0!==i;)s.push(i),i=o.get(i);const r=s.reverse();t[1]===_&&(u=r),n.push(r)}}for(let t=0;t<g;++t){const e=this.getEndsOfEdge(f[t]);if(e){const[s]=e,i=f[t].weight,r=h.get(s);r&&r!==1/0&&r+i<r&&(l=!0)}}return{hasNegativeCycle:l,distMap:h,preMap:o,paths:n,min:a,minPath:u}}floyd(){var t;const e=[...this._vertices],s=e.length,i=[],r=[];for(let t=0;t<s;t++){i[t]=[],r[t]=[];for(let e=0;e<s;e++)r[t][e]=null}for(let r=0;r<s;r++)for(let n=0;n<s;n++)i[r][n]=(null===(t=this.getEdge(e[r][1],e[n][1]))||void 0===t?void 0:t.weight)||1/0;for(let t=0;t<s;t++)for(let n=0;n<s;n++)for(let h=0;h<s;h++)i[n][h]>i[n][t]+i[t][h]&&(i[n][h]=i[n][t]+i[t][h],r[n][h]=e[t][1]);return{costs:i,predecessor:r}}tarjan(t,e,s,i){const r=!1;void 0===t&&(t=r),void 0===e&&(e=r),void 0===s&&(s=r),void 0===i&&(i=r);const n=new Map,h=new Map,o=this._vertices;o.forEach((t=>{n.set(t,-1),h.set(t,1/0)}));const[l]=o.values(),a=[],u=[];let c=0;const d=(s,i)=>{c++,n.set(s,c),h.set(s,c);const r=this.getNeighbors(s);let o=0;for(const c of r)if(c!==i){-1===n.get(c)&&(o++,d(c,s));const i=h.get(c),r=h.get(s);void 0!==r&&void 0!==i&&h.set(s,Math.min(r,i));const f=n.get(s);if(void 0!==i&&void 0!==f&&(t&&(s===l&&o>=2||s!==l&&i>=f)&&a.push(s),e&&i>f)){const t=this.getEdge(s,c);t&&u.push(t)}}};d(l,null);let f=new Map;const g=()=>{const t=new Map;return h.forEach(((e,s)=>{var i;t.has(e)?null===(i=t.get(e))||void 0===i||i.push(s):t.set(e,[s])})),t};s&&(f=g());const _=new Map;if(i){let t=new Map;t.size<1&&(t=g()),t.forEach(((t,e)=>{t.length>1&&_.set(e,t)}))}return{dfnMap:n,lowMap:h,bridges:u,articulationPoints:a,SCCs:f,cycles:_}}_addVertexOnly(t){return!this.hasVertex(t)&&(this._vertices.set(t.key,t),!0)}_getVertex(t){const e=this._getVertexKey(t);return this._vertices.get(e)||null}_getVertexKey(t){return t instanceof N?t.key:t}_setVertices(t){this._vertices=t}}class I extends N{constructor(t,e){super(t,e)}}class F extends O{constructor(t,e,s,i){super(s,i),this._src=t,this._dest=e}get src(){return this._src}set src(t){this._src=t}get dest(){return this._dest}set dest(t){this._dest=t}}class P extends L{constructor(){super(),this._outEdgeMap=new Map,this._inEdgeMap=new Map}get outEdgeMap(){return this._outEdgeMap}get inEdgeMap(){return this._inEdgeMap}createVertex(t,e){return new I(t,null!=e?e:t)}createEdge(t,e,s,i){return new F(t,e,null!=s?s:1,i)}getEdge(t,e){let s=[];if(null!==t&&null!==e){const i=this._getVertex(t),r=this._getVertex(e);if(i&&r){const t=this._outEdgeMap.get(i);t&&(s=t.filter((t=>t.dest===r.key)))}}return s[0]||null}removeEdgeSrcToDest(t,e){const s=this._getVertex(t),i=this._getVertex(e);let r=null;if(!s||!i)return null;const n=this._outEdgeMap.get(s);n&&E(n,(t=>t.dest===i.key));const h=this._inEdgeMap.get(i);return h&&(r=E(h,(t=>t.src===s.key))[0]||null),r}removeEdge(t){let e=null;const s=this._getVertex(t.src),i=this._getVertex(t.dest);if(s&&i){const t=this._outEdgeMap.get(s);t&&t.length>0&&E(t,(t=>t.src===s.key));const r=this._inEdgeMap.get(i);r&&r.length>0&&(e=E(r,(t=>t.dest===i.key))[0])}return e}removeEdgesBetween(t,e){const s=[];if(t&&e){const i=this.removeEdgeSrcToDest(t,e),r=this.removeEdgeSrcToDest(e,t);i&&s.push(i),r&&s.push(r)}return s}incomingEdgesOf(t){const e=this._getVertex(t);return e&&this.inEdgeMap.get(e)||[]}outgoingEdgesOf(t){const e=this._getVertex(t);return e&&this._outEdgeMap.get(e)||[]}degreeOf(t){return this.outDegreeOf(t)+this.inDegreeOf(t)}inDegreeOf(t){return this.incomingEdgesOf(t).length}outDegreeOf(t){return this.outgoingEdgesOf(t).length}edgesOf(t){return[...this.outgoingEdgesOf(t),...this.incomingEdgesOf(t)]}getEdgeSrc(t){return this._getVertex(t.src)}getEdgeDest(t){return this._getVertex(t.dest)}getDestinations(t){if(null===t)return[];const e=[],s=this.outgoingEdgesOf(t);for(const t of s){const s=this.getEdgeDest(t);s&&e.push(s)}return e}topologicalSort(t){t=null!=t?t:"key";const e=new Map;for(const t of this.vertices)e.set(t[1],0);let s=[],i=!1;const r=t=>{e.set(t,1);const n=this.getDestinations(t);for(const t of n){const s=e.get(t);0===s?r(t):1===s&&(i=!0)}e.set(t,2),s.push(t)};for(const t of this.vertices)0===e.get(t[1])&&r(t[1]);return i?null:("key"===t&&(s=s.map((t=>t instanceof I?t.key:t))),s.reverse())}edgeSet(){let t=[];return this._outEdgeMap.forEach((e=>{t=[...t,...e]})),t}getNeighbors(t){const e=[],s=this._getVertex(t);if(s){const t=this.outgoingEdgesOf(s);for(const s of t){const t=this._getVertex(s.dest);t&&e.push(t)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.src,t.dest))return null;const e=this._getVertex(t.src),s=this._getVertex(t.dest);return e&&s?[e,s]:null}_addEdgeOnly(t){if(!this.hasVertex(t.src)||!this.hasVertex(t.dest))return!1;const e=this._getVertex(t.src),s=this._getVertex(t.dest);if(e&&s){const i=this._outEdgeMap.get(e);i?i.push(t):this._outEdgeMap.set(e,[t]);const r=this._inEdgeMap.get(s);return r?r.push(t):this._inEdgeMap.set(s,[t]),!0}return!1}_setOutEdgeMap(t){this._outEdgeMap=t}_setInEdgeMap(t){this._inEdgeMap=t}}class D extends N{constructor(t,e){super(t,e)}}class B extends O{constructor(t,e,s,i){super(s,i),this._vertices=[t,e]}get vertices(){return this._vertices}set vertices(t){this._vertices=t}}class H extends L{constructor(){super(),this._edges=new Map}get edges(){return this._edges}createVertex(t,e){return new D(t,null!=e?e:t)}createEdge(t,e,s,i){return new B(t,e,null!=s?s:1,i)}getEdge(t,e){var s;let i=[];if(null!==t&&null!==e){const r=this._getVertex(t),n=this._getVertex(e);r&&n&&(i=null===(s=this._edges.get(r))||void 0===s?void 0:s.filter((t=>t.vertices.includes(n.key))))}return i&&i[0]||null}removeEdgeBetween(t,e){const s=this._getVertex(t),i=this._getVertex(e);if(!s||!i)return null;const r=this._edges.get(s);let n=null;r&&(n=E(r,(t=>t.vertices.includes(i.key)))[0]||null);const h=this._edges.get(i);return h&&E(h,(t=>t.vertices.includes(s.key))),n}removeEdge(t){return this.removeEdgeBetween(t.vertices[0],t.vertices[1])}degreeOf(t){var e;const s=this._getVertex(t);return s&&(null===(e=this._edges.get(s))||void 0===e?void 0:e.length)||0}edgesOf(t){const e=this._getVertex(t);return e&&this._edges.get(e)||[]}edgeSet(){const t=new Set;return this._edges.forEach((e=>{e.forEach((e=>{t.add(e)}))})),[...t]}getNeighbors(t){const e=[],s=this._getVertex(t);if(s){const t=this.edgesOf(s);for(const i of t){const t=this._getVertex(i.vertices.filter((t=>t!==s.key))[0]);t&&e.push(t)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.vertices[0],t.vertices[1]))return null;const e=this._getVertex(t.vertices[0]),s=this._getVertex(t.vertices[1]);return e&&s?[e,s]:null}_addEdgeOnly(t){for(const e of t.vertices){const s=this._getVertex(e);if(null===s)return!1;if(s){const e=this._edges.get(s);e?e.push(t):this._edges.set(s,[t])}}return!0}_setEdges(t){this._edges=t}}class q extends I{constructor(t,e,s,i){super(t,i),this._lat=e,this._long=s}get lat(){return this._lat}set lat(t){this._lat=t}get long(){return this._long}set long(t){this._long=t}}class j extends F{constructor(t,e,s,i){super(t,e,s,i)}}class U extends P{constructor(t,e){super(),this._origin=[0,0],this._origin=t,this._bottomRight=e}get origin(){return this._origin}set origin(t){this._origin=t}get bottomRight(){return this._bottomRight}set bottomRight(t){this._bottomRight=t}createVertex(t,e,s=this.origin[0],i=this.origin[1]){return new q(t,s,i,e)}createEdge(t,e,s,i){return new j(t,e,s,i)}}var K,G,W,Q,Y;!function(t){t.ITERATIVE="ITERATIVE",t.RECURSIVE="RECURSIVE"}(K||(K={})),function(t){t.ROOT="ROOT",t.LEFT="LEFT",t.RIGHT="RIGHT",t.ROOT_LEFT="ROOT_LEFT",t.ROOT_RIGHT="ROOT_RIGHT",t.ISOLATED="ISOLATED",t.MAL_NODE="MAL_NODE"}(G||(G={})),function(t){t.lt="lt",t.eq="eq",t.gt="gt"}(W||(W={})),function(t){t.RED="RED",t.BLACK="BLACK"}(Q||(Q={})),function(t){t.VAL="VAL",t.NODE="NODE",t.ID="ID"}(Y||(Y={}));class J{constructor(t,e){this.key=t,this.val=e}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get familyPosition(){const t=this;return t.parent?t.parent.left===t?t.left||t.right?G.ROOT_LEFT:G.LEFT:t.parent.right===t?t.left||t.right?G.ROOT_RIGHT:G.RIGHT:G.MAL_NODE:t.left||t.right?G.ROOT:G.ISOLATED}}class X{constructor(t){if(this._root=null,this._size=0,this._loopType=K.ITERATIVE,this._defaultCallbackByKey=t=>t.key,void 0!==t){const{iterationType:e=K.ITERATIVE}=t;this._loopType=e}}createNode(t,e){return new J(t,e)}get root(){return this._root}get size(){return this._size}get iterationType(){return this._loopType}set iterationType(t){this._loopType=t}_swap(t,e){const{key:s,val:i}=e,r=this.createNode(s,i);return r&&(e.key=t.key,e.val=t.val,t.key=r.key,t.val=r.val),e}clear(){this._root=null,this._size=0}isEmpty(){return 0===this.size}add(t,e){let s,i;if(null===t)i=null;else if("number"==typeof t)i=this.createNode(t,e);else{if(!(t instanceof J))return;i=t}const r=t?this.get(t,this._defaultCallbackByKey):void 0;return this.root?r?(r.val=e,s=r):s=((t,e)=>{const s=new v([t]);for(;s.size>0;){const t=s.shift();if(!t)return;{if(e&&t.key===e.key)return;const i=this._addTo(e,t);if(void 0!==i)return i;t.left&&s.push(t.left),t.right&&s.push(t.right)}}})(this.root,i):(this._setRoot(i),null!==i?this._setSize(1):this._setSize(0),s=this.root),s}addMany(t,e){const s=[];for(let i=0;i<t.length;i++){const r=t[i];if(r instanceof J){s.push(this.add(r.key,r.val));continue}if(null===r){s.push(this.add(null));continue}const n=null==e?void 0:e[i];s.push(this.add(r,n))}return s}refill(t,e){return this.clear(),t.length===this.addMany(t,e).length}delete(t){const e=[];if(!this.root)return e;const s="number"==typeof t?this.get(t):t;if(!s)return e;const i=(null==s?void 0:s.parent)?s.parent:null;let r=null,n=s;if(s.left){const t=s.left?this.getRightMost(s.left):null;if(t){const e=t.parent;n=this._swap(s,t),e&&(e.right===t?e.right=t.left:e.left=t.left,r=e)}}else if(i){const{familyPosition:t}=s;t===G.LEFT||t===G.ROOT_LEFT?i.left=s.right:t!==G.RIGHT&&t!==G.ROOT_RIGHT||(i.right=s.right),r=i}else void 0!==s.right&&this._setRoot(s.right);return this._setSize(this.size-1),e.push({deleted:n,needBalanced:r}),e}getDepth(t,e=this.root){"number"==typeof t&&(t=this.get(t)),"number"==typeof e&&(e=this.get(e));let s=0;for(;null==t?void 0:t.parent;){if(t===e)return s;s++,t=t.parent}return s}getHeight(t=this.root,e=this.iterationType){if("number"==typeof t&&(t=this.get(t)),!t)return-1;if(e===K.RECURSIVE){const e=t=>{if(!t)return-1;const s=e(t.left),i=e(t.right);return Math.max(s,i)+1};return e(t)}{if(!t)return-1;const e=[{node:t,depth:0}];let s=0;for(;e.length>0;){const{node:t,depth:i}=e.pop();t.left&&e.push({node:t.left,depth:i+1}),t.right&&e.push({node:t.right,depth:i+1}),s=Math.max(s,i)}return s}}getMinHeight(t=this.root,e=this.iterationType){var s,i,r;if(!t)return-1;if(e===K.RECURSIVE){const e=t=>{if(!t)return 0;if(!t.left&&!t.right)return 0;const s=e(t.left),i=e(t.right);return Math.min(s,i)+1};return e(t)}{const e=[];let n=t,h=null;const o=new Map;for(;e.length>0||n;)if(n)e.push(n),n=n.left;else if(n=e[e.length-1],n.right&&h!==n.right)n=n.right;else if(n=e.pop(),n){const t=n.left&&null!==(s=o.get(n.left))&&void 0!==s?s:-1,e=n.right&&null!==(i=o.get(n.right))&&void 0!==i?i:-1;o.set(n,1+Math.min(t,e)),h=n,n=null}return null!==(r=o.get(t))&&void 0!==r?r:-1}}isPerfectlyBalanced(t=this.root){return this.getMinHeight(t)+1>=this.getHeight(t)}getNodes(t,e=this._defaultCallbackByKey,s=!1,i=this.root,r=this.iterationType){if(!i)return[];const n=[];if(r===K.RECURSIVE){const r=i=>{e(i)===t&&(n.push(i),s)||(i.left||i.right)&&(i.left&&r(i.left),i.right&&r(i.right))};r(i)}else{const r=new v([i]);for(;r.size>0;){const i=r.shift();if(i){if(e(i)===t&&(n.push(i),s))return n;i.left&&r.push(i.left),i.right&&r.push(i.right)}}}return n}has(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){return this.getNodes(t,e,!0,s,i).length>0}get(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){var r;return null!==(r=this.getNodes(t,e,!0,s,i)[0])&&void 0!==r?r:null}getPathToRoot(t,e=!0){const s=[];for(;t.parent;)s.push(t),t=t.parent;return s.push(t),e?s.reverse():s}getLeftMost(t=this.root,e=this.iterationType){if("number"==typeof t&&(t=this.get(t)),!t)return t;if(e===K.RECURSIVE){const e=t=>t.left?e(t.left):t;return e(t)}{const e=T((t=>t.left?e.cont(t.left):t));return e(t)}}getRightMost(t=this.root,e=this.iterationType){if(!t)return t;if(e===K.RECURSIVE){const e=t=>t.right?e(t.right):t;return e(t)}{const e=T((t=>t.right?e.cont(t.right):t));return e(t)}}isSubtreeBST(t,e=this.iterationType){if(!t)return!0;if(e===K.RECURSIVE){const e=(t,s,i)=>!t||!(t.key<=s||t.key>=i)&&e(t.left,s,t.key)&&e(t.right,t.key,i);return e(t,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)}{const e=[];let s=Number.MIN_SAFE_INTEGER,i=t;for(;i||e.length>0;){for(;i;)e.push(i),i=i.left;if(i=e.pop(),!i||s>=i.key)return!1;s=i.key,i=i.right}return!0}}isBST(t=this.iterationType){return null===this.root||this.isSubtreeBST(this.root,t)}subTreeTraverse(t=this._defaultCallbackByKey,e=this.root,s=this.iterationType){"number"==typeof e&&(e=this.get(e));const i=[];if(!e)return i;if(s===K.RECURSIVE){const s=e=>{i.push(t(e)),e.left&&s(e.left),e.right&&s(e.right)};s(e)}else{const s=[e];for(;s.length>0;){const e=s.pop();i.push(t(e)),e.right&&s.push(e.right),e.left&&s.push(e.left)}}return i}dfs(t=this._defaultCallbackByKey,e="in",s=this.root,i=K.ITERATIVE){if(!s)return[];const r=[];if(i===K.RECURSIVE){const i=s=>{switch(e){case"in":s.left&&i(s.left),r.push(t(s)),s.right&&i(s.right);break;case"pre":r.push(t(s)),s.left&&i(s.left),s.right&&i(s.right);break;case"post":s.left&&i(s.left),s.right&&i(s.right),r.push(t(s))}};i(s)}else{const i=[{opt:0,node:s}];for(;i.length>0;){const s=i.pop();if(s&&s.node)if(1===s.opt)r.push(t(s.node));else switch(e){case"in":default:i.push({opt:0,node:s.node.right}),i.push({opt:1,node:s.node}),i.push({opt:0,node:s.node.left});break;case"pre":i.push({opt:0,node:s.node.right}),i.push({opt:0,node:s.node.left}),i.push({opt:1,node:s.node});break;case"post":i.push({opt:1,node:s.node}),i.push({opt:0,node:s.node.right}),i.push({opt:0,node:s.node.left})}}}return r}bfs(t=this._defaultCallbackByKey,e=!1,s=this.root,i=this.iterationType){if(!s)return[];const r=[];if(i===K.RECURSIVE){const i=(s,n)=>{t&&r.push(t(s,e?n:void 0)),s.left&&i(s.left,n+1),s.right&&i(s.right,n+1)};i(s,0)}else{const i=[[s,0]];for(;i.length>0;){const s=i.pop(),[n,h]=s;t&&r.push(t(n,e?h:void 0)),n.right&&i.push([n.right,h+1]),n.left&&i.push([n.left,h+1])}}return r}getPredecessor(t){if(t.left){let e=t.left;for(;!e||e.right&&e.right!==t;)e&&(e=e.right);return e}return t}morris(t=this._defaultCallbackByKey,e="in",s=this.root){if(null===s)return[];const i=[];let r=s;const n=t=>{let e=null,s=null;for(;t;)s=t.right,t.right=e,e=t,t=s;return e},h=e=>{const s=n(e);let r=s;for(;r;)i.push(t(r)),r=r.right;n(s)};switch(e){case"in":for(;r;){if(r.left){const t=this.getPredecessor(r);if(!t.right){t.right=r,r=r.left;continue}t.right=null}i.push(t(r)),r=r.right}break;case"pre":for(;r;){if(r.left){const e=this.getPredecessor(r);if(!e.right){e.right=r,i.push(t(r)),r=r.left;continue}e.right=null}else i.push(t(r));r=r.right}break;case"post":for(;r;){if(r.left){const t=this.getPredecessor(r);if(null===t.right){t.right=r,r=r.left;continue}t.right=null,h(r.left)}r=r.right}h(s)}return i}_addTo(t,e){return e?void 0===e.left?(e.left=t,t&&this._setSize(this.size+1),e.left):void 0===e.right?(e.right=t,t&&this._setSize(this.size+1),e.right):void 0:void 0}_setRoot(t){t&&(t.parent=void 0),this._root=t}_setSize(t){this._size=t}}class Z extends J{constructor(t,e){super(t,e)}}class $ extends X{constructor(t){if(super(t),this._comparator=(t,e)=>t-e,void 0!==t){const{comparator:e}=t;void 0!==e&&(this._comparator=e)}}createNode(t,e){return new Z(t,e)}add(t,e){let s=null,i=null;if(t instanceof Z?i=t:"number"==typeof t?i=this.createNode(t,e):null===t&&(i=null),null===this.root)this._setRoot(i),this._setSize(this.size+1),s=this.root;else{let t=this.root,e=!0;for(;e;)null!==t&&null!==i?this._compare(t.key,i.key)===W.eq?(i&&(t.val=i.val),e=!1,s=t):this._compare(t.key,i.key)===W.gt?void 0===t.left?(i&&(i.parent=t),t.left=i,this._setSize(this.size+1),e=!1,s=t.left):t.left&&(t=t.left):this._compare(t.key,i.key)===W.lt&&(void 0===t.right?(i&&(i.parent=t),t.right=i,this._setSize(this.size+1),e=!1,s=t.right):t.right&&(t=t.right)):e=!1}return s}addMany(t,e,s=!0,i=this.iterationType){if(!s||-1!==t.indexOf(null))return super.addMany(t,e);const r=[],n=t.map(((t,s)=>[t,null==e?void 0:e[s]]));let h=[],o=[],l=[];if(function(t){for(const[e]of t)if(e instanceof Z)return!0;return!1}(n))h=n.sort(((t,e)=>t[0].key-e[0].key));else{if(!function(t){for(const[e]of t)if("number"==typeof e)return!0;return!1}(n))throw new Error("Invalid input keysOrNodes");h=n.sort(((t,e)=>t[0]-e[0]))}o=h.map((([t])=>t)),l=h.map((([,t])=>t));const a=(t,e)=>{if(0===t.length)return;const s=Math.floor((t.length-1)/2),i=this.add(t[s],null==e?void 0:e[s]);r.push(i),a(t.slice(0,s),null==e?void 0:e.slice(0,s)),a(t.slice(s+1),null==e?void 0:e.slice(s+1))};return i===K.RECURSIVE?a(o,l):(()=>{const t=[[0,h.length-1]];for(;t.length>0;){const e=t.pop();if(e){const[s,i]=e;if(s<=i){const e=s+Math.floor((i-s)/2),n=this.add(o[e],null==l?void 0:l[e]);r.push(n),t.push([e+1,i]),t.push([s,e-1])}}}})(),r}get(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){var r;return null!==(r=this.getNodes(t,e,!0,s,i)[0])&&void 0!==r?r:null}lastKey(t=this.root,e=this.iterationType){var s,i,r,n,h,o;return this._compare(0,1)===W.lt?null!==(i=null===(s=this.getRightMost(t,e))||void 0===s?void 0:s.key)&&void 0!==i?i:0:this._compare(0,1)===W.gt?null!==(n=null===(r=this.getLeftMost(t,e))||void 0===r?void 0:r.key)&&void 0!==n?n:0:null!==(o=null===(h=this.getRightMost(t,e))||void 0===h?void 0:h.key)&&void 0!==o?o:0}getNodes(t,e=this._defaultCallbackByKey,s=!1,i=this.root,r=this.iterationType){if(!i)return[];const n=[];if(r===K.RECURSIVE){const r=i=>{e(i)===t&&(n.push(i),s)||(i.left||i.right)&&(e===this._defaultCallbackByKey?(this._compare(i.key,t)===W.gt&&i.left&&r(i.left),this._compare(i.key,t)===W.lt&&i.right&&r(i.right)):(i.left&&r(i.left),i.right&&r(i.right)))};r(i)}else{const r=new v([i]);for(;r.size>0;){const i=r.shift();if(i){if(e(i)===t&&(n.push(i),s))return n;e===this._defaultCallbackByKey?(this._compare(i.key,t)===W.gt&&i.left&&r.push(i.left),this._compare(i.key,t)===W.lt&&i.right&&r.push(i.right)):(i.left&&r.push(i.left),i.right&&r.push(i.right))}}}return n}lesserOrGreaterTraverse(t=this._defaultCallbackByKey,e=W.lt,s=this.root,i=this.iterationType){"number"==typeof s&&(s=this.get(s));const r=[];if(!s)return r;const n=s.key;if(!this.root)return r;if(i===K.RECURSIVE){const s=i=>{this._compare(i.key,n)===e&&r.push(t(i)),(i.left||i.right)&&(i.left&&this._compare(i.left.key,n)===e&&s(i.left),i.right&&this._compare(i.right.key,n)===e&&s(i.right))};return s(this.root),r}{const s=new v([this.root]);for(;s.size>0;){const i=s.shift();i&&(this._compare(i.key,n)===e&&r.push(t(i)),i.left&&this._compare(i.left.key,n)===e&&s.push(i.left),i.right&&this._compare(i.right.key,n)===e&&s.push(i.right))}return r}}perfectlyBalance(t=this.iterationType){const e=this.dfs((t=>t),"in"),s=e.length;if(this.clear(),e.length<1)return!1;if(t===K.RECURSIVE){const t=(s,i)=>{if(s>i)return;const r=s+Math.floor((i-s)/2),n=e[r];this.add(n.key,n.val),t(s,r-1),t(r+1,i)};return t(0,s-1),!0}{const t=[[0,s-1]];for(;t.length>0;){const s=t.pop();if(s){const[i,r]=s;if(i<=r){const s=i+Math.floor((r-i)/2),n=e[s];this.add(n.key,n.val),t.push([s+1,r]),t.push([i,s-1])}}}return!0}}isAVLBalanced(t=this.iterationType){var e,s;if(!this.root)return!0;let i=!0;if(t===K.RECURSIVE){const t=e=>{if(!e)return 0;const s=t(e.left),r=t(e.right);return Math.abs(s-r)>1&&(i=!1),Math.max(s,r)+1};t(this.root)}else{const t=[];let i=this.root,r=null;const n=new Map;for(;t.length>0||i;)if(i)t.push(i),i=i.left;else if(i=t[t.length-1],i.right&&r!==i.right)i=i.right;else if(i=t.pop(),i){const t=i.left&&null!==(e=n.get(i.left))&&void 0!==e?e:-1,h=i.right&&null!==(s=n.get(i.right))&&void 0!==s?s:-1;if(Math.abs(t-h)>1)return!1;n.set(i,1+Math.max(t,h)),r=i,i=null}}return i}_compare(t,e){const s=this._comparator(t,e);return s>0?W.gt:s<0?W.lt:W.eq}}class tt{constructor({frequency:t=0,max:e}){this._freq=t,this._max=e,this._freqMap={0:0},this._msb=R(e),this._negativeCount=t<0?e:0}get freqMap(){return this._freqMap}set freqMap(t){this._freqMap=t}get msb(){return this._msb}set msb(t){this._msb=t}get negativeCount(){return this._negativeCount}set negativeCount(t){this._negativeCount=t}get freq(){return this._freq}get max(){return this._max}readSingle(t){return this._checkIndex(t),this._readSingle(t)}update(t,e){this._checkIndex(t);const s=this._readSingle(t);this._update(t,e),this._updateNegativeCount(s,s+e)}writeSingle(t,e){this._checkIndex(t),this._writeSingle(t,e)}read(t){if(!Number.isInteger(t))throw new Error("Invalid count");return this._read(Math.max(Math.min(t,this.max),0))}lowerBound(t){if(this.negativeCount>0)throw new Error("Sequence is not non-descending");return this._binarySearch(t,((t,e)=>t<e))}upperBound(t){if(this.negativeCount>0)throw new Error("Must not be descending");return this._binarySearch(t,((t,e)=>t<=e))}_getFrequency(t){return t in this.freqMap?this.freqMap[t]:this.freq*(t&-t)}_updateFrequency(t,e){this.freqMap[t]=this._getFrequency(t)+e}_checkIndex(t){if(!Number.isInteger(t))throw new Error("Invalid index: Index must be an integer.");if(t<0||t>=this.max)throw new Error("Index out of range: Index must be within the range [0, this.max).")}_readSingle(t){t+=1;let e=this._getFrequency(t);const s=t-(t&-t);for(t--;t!==s;)e-=this._getFrequency(t),t-=t&-t;return e}_updateNegativeCount(t,e){t<0&&e>=0?this.negativeCount--:t>=0&&e<0&&this.negativeCount++}_update(t,e){for(t+=1;t<=this.max;)this._updateFrequency(t,e),t+=t&-t}_writeSingle(t,e){const s=this._readSingle(t);this._update(t,e-s),this._updateNegativeCount(s,e)}_read(t){let e=t,s=0;for(;e;)s+=this._getFrequency(e),e-=e&-e;return s}_binarySearch(t,e){let s=0,i=this.msb<<1,r=t;for(;i>s+1;){const t=s+i>>1,n=this._getFrequency(t);t<=this.max&&e(n,r)?(r-=n,s=t):i=t}return s}}class et{constructor(t,e,s,i){this._start=0,this._end=0,this._val=null,this._sum=0,this._left=null,this._right=null,this._start=t,this._end=e,this._sum=s,this._val=i||null}get start(){return this._start}set start(t){this._start=t}get end(){return this._end}set end(t){this._end=t}get val(){return this._val}set val(t){this._val=t}get sum(){return this._sum}set sum(t){this._sum=t}get left(){return this._left}set left(t){this._left=t}get right(){return this._right}set right(t){this._right=t}}class st{constructor(t,e,s){this._values=[],this._start=0,e=e||0,s=s||t.length-1,this._values=t,this._start=e,this._end=s,t.length>0?this._root=this.build(e,s):(this._root=null,this._values=[])}get values(){return this._values}get start(){return this._start}get end(){return this._end}get root(){return this._root}build(t,e){if(t>e)return new et(t,e,0);if(t===e)return new et(t,e,this._values[t]);const s=t+Math.floor((e-t)/2),i=this.build(t,s),r=this.build(s+1,e),n=new et(t,e,i.sum+r.sum);return n.left=i,n.right=r,n}updateNode(t,e,s){const i=this.root||null;if(!i)return;const r=(t,e,s,i)=>{if(t.start===t.end&&t.start===e)return t.sum=s,void(void 0!==i&&(t.val=i));e<=t.start+Math.floor((t.end-t.start)/2)?t.left&&r(t.left,e,s,i):t.right&&r(t.right,e,s,i),t.left&&t.right&&(t.sum=t.left.sum+t.right.sum)};r(i,t,e,s)}querySumByRange(t,e){const s=this.root||null;if(!s)return 0;if(t<0||e>=this.values.length||t>e)return NaN;const i=(t,e,s)=>{if(e<=t.start&&s>=t.end)return t.sum;const r=t.start+Math.floor((t.end-t.start)/2);if(s<=r)return t.left?i(t.left,e,s):NaN;if(e>r)return t.right?i(t.right,e,s):NaN;{let n=0,h=0;return t.left&&(n=i(t.left,e,r)),t.right&&(h=i(t.right,r+1,s)),n+h}};return i(s,t,e)}_setValues(t){this._values=t}_setStart(t){this._start=t}_setEnd(t){this._end=t}_setRoot(t){this._root=t}}class it extends Z{constructor(t,e){super(t,e),this.height=0}}class rt extends ${constructor(t){super(t)}_swap(t,e){const{key:s,val:i,height:r}=e,n=this.createNode(s,i);return n&&(n.height=r,e.key=t.key,e.val=t.val,e.height=t.height,t.key=n.key,t.val=n.val,t.height=n.height),e}createNode(t,e){return new it(t,e)}add(t,e){const s=super.add(t,e);return s&&this._balancePath(s),s}delete(t){const e=super.delete(t);for(const{needBalanced:t}of e)t&&this._balancePath(t);return e}_balanceFactor(t){return t.right?t.left?t.right.height-t.left.height:+t.height:-t.height}_updateHeight(t){if(t.left||t.right)if(t.left)t.right?t.height=1+Math.max(t.right.height,t.left.height):t.height=1+t.left.height;else{const e=t.right?t.right.height:0;t.height=1+e}else t.height=0}_balancePath(t){const e=this.getPathToRoot(t,!1);for(let t=0;t<e.length;t++){const s=e[t];switch(this._updateHeight(s),this._balanceFactor(s)){case-2:s&&s.left&&(this._balanceFactor(s.left)<=0?this._balanceLL(s):this._balanceLR(s));break;case 2:s&&s.right&&(this._balanceFactor(s.right)>=0?this._balanceRR(s):this._balanceRL(s))}}}_balanceLL(t){const e=t.parent,s=t.left;t.parent=s,s&&s.right&&(s.right.parent=t),s&&(s.parent=e),t===this.root?s&&this._setRoot(s):(null==e?void 0:e.left)===t?e.left=s:e&&(e.right=s),s&&(t.left=s.right,s.right=t),this._updateHeight(t),s&&this._updateHeight(s)}_balanceLR(t){const e=t.parent,s=t.left;let i=null;s&&(i=s.right),t&&(t.parent=i),s&&(s.parent=i),i&&(i.left&&(i.left.parent=s),i.right&&(i.right.parent=t),i.parent=e),t===this.root?i&&this._setRoot(i):e&&(e.left===t?e.left=i:e.right=i),i&&(t.left=i.right,s&&(s.right=i.left),i.left=s,i.right=t),this._updateHeight(t),s&&this._updateHeight(s),i&&this._updateHeight(i)}_balanceRR(t){const e=t.parent,s=t.right;t.parent=s,s&&(s.left&&(s.left.parent=t),s.parent=e),t===this.root?s&&this._setRoot(s):e&&(e.left===t?e.left=s:e.right=s),s&&(t.right=s.left,s.left=t),this._updateHeight(t),s&&this._updateHeight(s)}_balanceRL(t){const e=t.parent,s=t.right;let i=null;s&&(i=s.left),t.parent=i,s&&(s.parent=i),i&&(i.left&&(i.left.parent=t),i.right&&(i.right.parent=s),i.parent=e),t===this.root?i&&this._setRoot(i):e&&(e.left===t?e.left=i:e.right=i),i&&(t.right=i.left),s&&i&&(s.left=i.right),i&&(i.left=t),i&&(i.right=s),this._updateHeight(t),s&&this._updateHeight(s),i&&this._updateHeight(i)}}class nt extends Z{constructor(t,e){super(t,e),this._color=Q.RED}get color(){return this._color}set color(t){this._color=t}}class ht extends ${constructor(t){super(t)}createNode(t,e){return new nt(t,e)}}class ot extends it{constructor(t,e,s=1){super(t,e),this.count=s}}class lt extends rt{constructor(t){super(t),this._count=0}get count(){return this._count}createNode(t,e,s){return new ot(t,e,s)}_swap(t,e){const{key:s,val:i,count:r,height:n}=e,h=this.createNode(s,i,r);return h&&(h.height=n,e.key=t.key,e.val=t.val,e.count=t.count,e.height=t.height,t.key=h.key,t.val=h.val,t.count=h.count,t.height=h.height),e}add(t,e,s=1){let i,r;if(r=t instanceof ot?this.createNode(t.key,t.val,t.count):null===t?null:this.createNode(t,e,s),this.root){let t=this.root,e=!0;for(;e;)t?r&&(this._compare(t.key,r.key)===W.eq?(t.val=r.val,t.count+=r.count,this._setCount(this.count+r.count),e=!1,i=t):this._compare(t.key,r.key)===W.gt?void 0===t.left?(t.left=r,this._setSize(this.size+1),this._setCount(this.count+r.count),e=!1,i=t.left):t.left&&(t=t.left):this._compare(t.key,r.key)===W.lt&&(void 0===t.right?(t.right=r,this._setSize(this.size+1),this._setCount(this.count+r.count),e=!1,i=t.right):t.right&&(t=t.right))):e=!1}else this._setRoot(r),this._setSize(this.size+1),r&&this._setCount(this.count+r.count),i=this.root;return i&&this._balancePath(i),i}_addTo(t,e){return e?void 0===e.left?(e.left=t,null!==t&&(this._setSize(this.size+1),this._setCount(this.count+t.count)),e.left):void 0===e.right?(e.right=t,null!==t&&(this._setSize(this.size+1),this._setCount(this.count+t.count)),e.right):void 0:void 0}addMany(t,e){const s=[];for(let i=0;i<t.length;i++){const r=t[i];r instanceof ot?s.push(this.add(r.key,r.val,r.count)):null!==r?s.push(this.add(r,null==e?void 0:e[i],1)):s.push(this.add(NaN,null,0))}return s}perfectlyBalance(t=this.iterationType){const e=this.dfs((t=>t),"in"),s=e.length;if(e.length<1)return!1;if(this.clear(),t===K.RECURSIVE){const t=(s,i)=>{if(s>i)return;const r=s+Math.floor((i-s)/2),n=e[r];this.add(n.key,n.val,n.count),t(s,r-1),t(r+1,i)};return t(0,s-1),!0}{const t=[[0,s-1]];for(;t.length>0;){const s=t.pop();if(s){const[i,r]=s;if(i<=r){const s=i+Math.floor((r-i)/2),n=e[s];this.add(n.key,n.val,n.count),t.push([s+1,r]),t.push([i,s-1])}}}return!0}}delete(t,e=!1){const s=[];if(!this.root)return s;const i=this.get(t);if(!i)return s;const r=(null==i?void 0:i.parent)?i.parent:null;let n=null,h=i;if(i.count>1&&!e)i.count--,this._setCount(this.count-1);else{if(i.left){const t=i.left?this.getRightMost(i.left):null;if(t){const e=t.parent;h=this._swap(i,t),e&&(e.right===t?e.right=t.left:e.left=t.left,n=e)}}else if(r){const{familyPosition:t}=i;t===G.LEFT||t===G.ROOT_LEFT?r.left=i.right:t!==G.RIGHT&&t!==G.ROOT_RIGHT||(r.right=i.right),n=r}else void 0!==i.right&&this._setRoot(i.right);this._setSize(this.size-1),this._setCount(this.count-h.count)}return s.push({deleted:h,needBalanced:n}),n&&this._balancePath(n),s}clear(){super.clear(),this._setCount(0)}_setCount(t){this._count=t}}class at{constructor(t,e,s){this._key=t,this._value=e||void 0,this._children=s||[]}get key(){return this._key}set key(t){this._key=t}get value(){return this._value}set value(t){this._value=t}get children(){return this._children}set children(t){this._children=t}addChildren(t){this.children||(this.children=[]),t instanceof at?this.children.push(t):this.children=this.children.concat(t)}getHeight(){let t=0;if(this){const e=(s,i)=>{i>t&&(t=i);const{children:r}=s;if(r)for(let t=0,s=r.length;t<s;t++)e(r[t],i+1)};e(this,0)}return t}}class ut extends z{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return e-t})){super(t)}}class ct extends z{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return t-e})){super(t)}}class dt extends A{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return t-e})){super(t)}}class ft extends A{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return e-t})){super(t)}}class gt{constructor(t){const{row:e,col:s,initialVal:i}=t;this._matrix=new Array(e).fill(void 0).map((()=>new Array(s).fill(i||0)))}toArray(){return this._matrix}}class _t{constructor(t=0,e=0,s=1){this.x=t,this.y=e,this.w=s}get isZero(){return 0===this.x&&0===this.y}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}get lengthSq(){return this.x*this.x+this.y*this.y}get rounded(){return new _t(Math.round(this.x),Math.round(this.y))}static add(t,e){return new _t(t.x+e.x,t.y+e.y)}static subtract(t,e){return new _t(t.x-e.x,t.y-e.y)}static subtractValue(t,e){return new _t(t.x-e,t.y-e)}static multiply(t,e){return new _t(t.x*e,t.y*e)}static divide(t,e){return new _t(t.x/e,t.y/e)}static equals(t,e){return t.x===e.x&&t.y===e.y}static equalsRounded(t,e,s=12){const i=_t.abs(_t.subtract(t,e));return i.x<s&&i.y<s}static normalize(t){const e=t.length;return e>2220446049250313e-31?_t.divide(t,e):t}static truncate(t,e){return t.length>e?_t.multiply(_t.normalize(t),e):t}static perp(t){return new _t(-t.y,t.x)}static reverse(t){return new _t(-t.x,-t.y)}static abs(t){return new _t(Math.abs(t.x),Math.abs(t.y))}static dot(t,e){return t.x*e.x+t.y*e.y}static distance(t,e){const s=e.y-t.y,i=e.x-t.x;return Math.sqrt(s*s+i*i)}static distanceSq(t,e){const s=e.y-t.y,i=e.x-t.x;return s*s+i*i}static sign(t,e){return t.y*e.x>t.x*e.y?-1:1}static angle(t){const e=new _t(0,-1),s=Math.acos(_t.dot(t,e)/(t.length*e.length));return 1===_t.sign(t,e)?2*Math.PI-s:s}static random(t,e){const s=Math.floor(Math.random()*t-t/2),i=Math.floor(Math.random()*e-e/2);return new _t(s,i)}zero(){this.x=0,this.y=0}}const pt=_t;class vt{constructor(t){void 0===t?this._matrix=vt.identity:t instanceof pt?(this._matrix=vt.identity,this._matrix[0][0]=t.x,this._matrix[1][0]=t.y,this._matrix[2][0]=t.w):this._matrix=t}static get empty(){return[[],[],[]]}static get identity(){return[[1,0,0],[0,1,0],[0,0,1]]}get m(){return this._matrix}toVector(){return new pt(this._matrix[0][0],this._matrix[1][0])}static add(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]+e.m[i][r];return new vt(s)}static subtract(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]-e.m[i][r];return new vt(s)}static multiply(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++){s[i][r]=0;for(let n=0;n<3;n++)s[i][r]+=t.m[i][n]*e.m[n][r]}return new vt(s)}static multiplyByValue(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]*e;return new vt(s)}static multiplyByVector(t,e){return vt.multiply(t,new vt(e)).toVector()}static view(t,e){const s=t/2,i=e/2,r=Math.cos(Math.PI);return new vt([[1,0,s],[0,1*r,i],[0,0,1]])}static scale(t){return vt.multiplyByValue(new vt,t)}static rotate(t){const e=Math.cos(t),s=Math.sin(t);return new vt([[e,-s,0],[s,e,0],[0,0,1]])}static translate(t){return new vt([[1,0,t.x],[0,1,t.y],[0,0,t.w]])}}class yt{constructor(t,e){this.direction=t,this.turn=()=>new yt(e[t],e)}}class mt{constructor({matrix:t,turning:e,onMove:s,init:{cur:i,charDir:r,VISITED:n}}){this._matrix=t,this._cur=i,this._character=new yt(r,e),this.onMove=s,this.onMove&&this.onMove(this._cur),this._VISITED=n,this._matrix[this._cur[0]][this._cur[1]]=this._VISITED}start(){for(;this.check(this._character.direction)||this.check(this._character.turn().direction);){const{direction:t}=this._character;this.check(t)?this.move(t):this.check(this._character.turn().direction)&&(this._character=this._character.turn())}}check(t){let e,s;const i=this._matrix,[r,n]=this._cur;switch(t){case"up":if(s=i[r-1],!s)return!1;e=s[n];break;case"right":e=i[r][n+1];break;case"down":if(s=i[r+1],!s)return!1;e=s[n];break;case"left":e=i[r][n-1]}return void 0!==e&&e!==this._VISITED}move(t){switch(t){case"up":this._cur[0]--;break;case"right":this._cur[1]++;break;case"down":this._cur[0]++;break;case"left":this._cur[1]--}const[e,s]=this._cur;this._matrix[e][s]=this._VISITED,this.onMove&&this.onMove(this._cur)}}class xt{constructor(t){this._key=t,this._isEnd=!1,this._children=new Map}get key(){return this._key}set key(t){this._key=t}get children(){return this._children}set children(t){this._children=t}get isEnd(){return this._isEnd}set isEnd(t){this._isEnd=t}}class bt{constructor(t,e=!0){if(this._root=new xt(""),this._caseSensitive=e,t)for(const e of t)this.add(e)}get root(){return this._root}set root(t){this._root=t}add(t){t=this._caseProcess(t);let e=this.root;for(const s of t){let t=e.children.get(s);t||(t=new xt(s),e.children.set(s,t)),e=t}return e.isEnd=!0,!0}has(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return e.isEnd}_caseProcess(t){return this._caseSensitive||(t=t.toLowerCase()),t}delete(t){t=this._caseProcess(t);let e=!1;const s=(i,r)=>{const n=t[r],h=i.children.get(n);return!!h&&(r===t.length-1?!!h.isEnd&&(h.children.size>0?h.isEnd=!1:i.children.delete(n),e=!0,!0):!(!s(h,r+1)||i.isEnd||0!==h.children.size||(i.children.delete(n),0)))};return s(this.root,0),e}getHeight(){const t=this.root;let e=0;if(t){const s=(t,i)=>{i>e&&(e=i);const{children:r}=t;if(r)for(const t of r.entries())s(t[1],i+1)};s(t,0)}return e}hasPurePrefix(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return!e.isEnd}hasPrefix(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return!0}hasCommonPrefix(t){t=this._caseProcess(t);let e="";const s=i=>{e+=i.key,e!==t&&(i.isEnd||i&&i.children&&1===i.children.size&&s(Array.from(i.children.values())[0]))};return s(this.root),e===t}getLongestCommonPrefix(){let t="";const e=s=>{t+=s.key,s.isEnd||s&&s.children&&1===s.children.size&&e(Array.from(s.children.values())[0])};return e(this.root),t}getWords(t="",e=Number.MAX_SAFE_INTEGER){t=this._caseProcess(t);const s=[];let i=0,r=this.root;if(t)for(const e of t){const t=r.children.get(e);t&&(r=t)}return r!==this.root&&function t(r,n){for(const e of r.children.keys()){const s=r.children.get(e);void 0!==s&&t(s,n.concat(e))}if(r.isEnd){if(i>e-1)return;s.push(n),i++}}(r,t),s}}return e})()));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.dataStructureTyped=e():t.dataStructureTyped=e()}(self,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AVLTree:()=>rt,AVLTreeNode:()=>it,AbstractEdge:()=>O,AbstractGraph:()=>L,AbstractVertex:()=>N,ArrayDeque:()=>x,BST:()=>$,BSTNode:()=>Z,BinaryIndexedTree:()=>tt,BinaryTree:()=>X,BinaryTreeNode:()=>J,CP:()=>Y,Character:()=>yt,CoordinateMap:()=>r,CoordinateSet:()=>n,Deque:()=>y,DirectedEdge:()=>F,DirectedGraph:()=>P,DirectedVertex:()=>I,DoublyLinkedList:()=>d,DoublyLinkedListNode:()=>c,FamilyPosition:()=>G,FibonacciHeap:()=>C,FibonacciHeapNode:()=>V,HashMap:()=>l,HashTable:()=>i,HashTableNode:()=>s,Heap:()=>z,IterationType:()=>K,LinkedListQueue:()=>p,MapEdge:()=>j,MapGraph:()=>U,MapVertex:()=>q,Matrix2D:()=>vt,MatrixNTI2D:()=>gt,MaxHeap:()=>ut,MaxPriorityQueue:()=>ft,MinHeap:()=>ct,MinPriorityQueue:()=>dt,Navigator:()=>mt,ObjectDeque:()=>m,PriorityQueue:()=>A,Queue:()=>v,RBColor:()=>W,RBTree:()=>ht,RBTreeNode:()=>nt,SegmentTree:()=>st,SegmentTreeNode:()=>et,SinglyLinkedList:()=>u,SinglyLinkedListNode:()=>a,SkipList:()=>g,SkipListNode:()=>f,Stack:()=>_,THUNK_SYMBOL:()=>w,TopologicalProperty:()=>Q,TreeMap:()=>h,TreeMultiset:()=>lt,TreeMultisetNode:()=>ot,TreeNode:()=>at,TreeSet:()=>o,Trie:()=>bt,TrieNode:()=>xt,UndirectedEdge:()=>B,UndirectedGraph:()=>H,UndirectedVertex:()=>D,Vector2D:()=>_t,arrayRemove:()=>E,getMSB:()=>R,isThunk:()=>k,toThunk:()=>M,trampoline:()=>T,trampolineAsync:()=>S,uuidV4:()=>b});class s{constructor(t,e){this.key=t,this.val=e,this.next=null}}class i{get hashFn(){return this._hashFn}set hashFn(t){this._hashFn=t}get buckets(){return this._buckets}set buckets(t){this._buckets=t}get capacity(){return this._capacity}set capacity(t){this._capacity=t}constructor(t=i.DEFAULT_CAPACITY,e){this._hashFn=e||this._defaultHashFn,this._capacity=Math.max(t,i.DEFAULT_CAPACITY),this._size=0,this._buckets=new Array(this._capacity).fill(null)}_defaultHashFn(t){return("string"==typeof t?this._murmurStringHashFn(t):this._objectHash(t))%this._capacity}_multiplicativeStringHashFn(t){const e=String(t);let s=0;for(let t=0;t<e.length;t++)s=(.618033988749895*s+e.charCodeAt(t))%(1<<30);return Math.abs(s)}_murmurStringHashFn(t){const e=String(t);let s=0;for(let t=0;t<e.length;t++)s=1540483477*(s^e.charCodeAt(t)),s=668265261*(s^s>>>15),s^=s>>>15;return Math.abs(s)}_hash(t){return this.hashFn(t)}_stringHash(t){let e=0;for(let s=0;s<t.length;s++)e=31*e+t.charCodeAt(s)&4294967295;return e}_objectHash(t){return this._stringHash(JSON.stringify(t))}set(t,e){const r=this._hash(t),n=new s(t,e);if(this._buckets[r]){let s=this._buckets[r];for(;s;){if(s.key===t)return void(s.val=e);if(!s.next)break;s=s.next}s.next=n}else this._buckets[r]=n;this._size++,this._size/this._capacity>=i.LOAD_FACTOR&&this._expand()}get(t){const e=this._hash(t);let s=this._buckets[e];for(;s;){if(s.key===t)return s.val;s=s.next}}delete(t){const e=this._hash(t);let s=this._buckets[e],i=null;for(;s;){if(s.key===t)return i?i.next=s.next:this._buckets[e]=s.next,this._size--,void(s.next=null);i=s,s=s.next}}_expand(){const t=2*this._capacity,e=new Array(t).fill(null);for(const t of this._buckets){let i=t;for(;i;){const t=this._hash(i.key),r=new s(i.key,i.val);if(e[t]){let s=e[t];for(;s.next;)s=s.next;s.next=r}else e[t]=r;i=i.next}}this._buckets=e,this._capacity=t}get size(){return this._size}}i.DEFAULT_CAPACITY=16,i.LOAD_FACTOR=.75;class r extends Map{constructor(t){super(),this._joint="_",void 0!==t&&(this._joint=t)}get joint(){return this._joint}has(t){return super.has(t.join(this._joint))}set(t,e){return super.set(t.join(this._joint),e)}get(t){return super.get(t.join(this._joint))}delete(t){return super.delete(t.join(this._joint))}_setJoint(t){this._joint=t}}class n extends Set{constructor(t){super(),this._joint="_",void 0!==t&&(this._joint=t)}get joint(){return this._joint}has(t){return super.has(t.join(this._joint))}add(t){return super.add(t.join(this._joint))}delete(t){return super.delete(t.join(this._joint))}_setJoint(t){this._joint=t}}class h{}class o{}class l{get hashFn(){return this._hashFn}set hashFn(t){this._hashFn=t}get table(){return this._table}set table(t){this._table=t}get capacityMultiplier(){return this._capacityMultiplier}set capacityMultiplier(t){this._capacityMultiplier=t}get loadFactor(){return this._loadFactor}set loadFactor(t){this._loadFactor=t}get initialCapacity(){return this._initialCapacity}set initialCapacity(t){this._initialCapacity=t}get size(){return this._size}set size(t){this._size=t}constructor(t=16,e=.75,s){this._initialCapacity=t,this._loadFactor=e,this._capacityMultiplier=2,this._size=0,this._table=new Array(t),this._hashFn=s||(t=>{const e=String(t);let s=0;for(let t=0;t<e.length;t++)s+=e.charCodeAt(t);return s%this.table.length})}_hash(t){return this._hashFn(t)}resizeTable(t){const e=new Array(t);for(const s of this._table)if(s)for(const[i,r]of s){const s=this._hash(i)%t;e[s]||(e[s]=[]),e[s].push([i,r])}this._table=e}set(t,e){this.size/this.table.length>=this.loadFactor&&this.resizeTable(this.table.length*this.capacityMultiplier);const s=this._hash(t);this.table[s]||(this.table[s]=[]);for(let i=0;i<this.table[s].length;i++)if(this.table[s][i][0]===t)return void(this.table[s][i][1]=e);this.table[s].push([t,e]),this.size++}get(t){const e=this._hash(t);if(this.table[e])for(const[s,i]of this.table[e])if(s===t)return i}delete(t){const e=this._hash(t);if(this.table[e])for(let s=0;s<this.table[e].length;s++)if(this.table[e][s][0]===t)return this.table[e].splice(s,1),this.size--,void(this.size/this.table.length<this.loadFactor/this.capacityMultiplier&&this.resizeTable(this.table.length/this.capacityMultiplier))}*entries(){for(const t of this.table)if(t)for(const[e,s]of t)yield[e,s]}[Symbol.iterator](){return this.entries()}clear(){this.size=0,this.table=new Array(this.initialCapacity)}isEmpty(){return 0===this.size}}class a{constructor(t){this._val=t,this._next=null}get val(){return this._val}set val(t){this._val=t}get next(){return this._next}set next(t){this._next=t}}class u{constructor(){this._head=null,this._tail=null,this._length=0}get head(){return this._head}set head(t){this._head=t}get tail(){return this._tail}set tail(t){this._tail=t}get length(){return this._length}static fromArray(t){const e=new u;for(const s of t)e.push(s);return e}getLength(){return this._length}push(t){const e=new a(t);this.head?(this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),this._length++}pop(){if(!this.head)return;if(this.head===this.tail){const t=this.head.val;return this.head=null,this.tail=null,this._length--,t}let t=this.head;for(;t.next!==this.tail;)t=t.next;const e=this.tail.val;return t.next=null,this.tail=t,this._length--,e}shift(){if(!this.head)return;const t=this.head;return this.head=this.head.next,this._length--,t.val}unshift(t){const e=new a(t);this.head?(e.next=this.head,this.head=e):(this.head=e,this.tail=e),this._length++}getAt(t){if(t<0||t>=this.length)return;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e.val}getNodeAt(t){let e=this.head;for(let s=0;s<t;s++)e=e.next;return e}deleteAt(t){if(t<0||t>=this.length)return;if(0===t)return this.shift();if(t===this.length-1)return this.pop();const e=this.getNodeAt(t-1),s=e.next;return e.next=s.next,this._length--,s.val}delete(t){let e;e=t instanceof a?t.val:t;let s=this.head,i=null;for(;s;){if(s.val===e)return null===i?(this.head=s.next,s===this.tail&&(this.tail=null)):(i.next=s.next,s===this.tail&&(this.tail=i)),this._length--,!0;i=s,s=s.next}return!1}insertAt(t,e){if(t<0||t>this.length)return!1;if(0===t)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;const s=new a(e),i=this.getNodeAt(t-1);return s.next=i.next,i.next=s,this._length++,!0}isEmpty(){return 0===this.length}clear(){this._head=null,this._tail=null,this._length=0}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.val),e=e.next;return t}reverse(){if(!this.head||this.head===this.tail)return;let t=null,e=this.head,s=null;for(;e;)s=e.next,e.next=t,t=e,e=s;[this.head,this.tail]=[this.tail,this.head]}find(t){let e=this.head;for(;e;){if(t(e.val))return e.val;e=e.next}return null}indexOf(t){let e=0,s=this.head;for(;s;){if(s.val===t)return e;e++,s=s.next}return-1}findNode(t){let e=this.head;for(;e;){if(e.val===t)return e;e=e.next}return null}insertBefore(t,e){if(!this.head)return!1;let s;if(s=t instanceof a?t.val:t,this.head.val===s)return this.unshift(e),!0;let i=this.head;for(;i.next;){if(i.next.val===s){const t=new a(e);return t.next=i.next,i.next=t,this._length++,!0}i=i.next}return!1}insertAfter(t,e){let s;if(s=t instanceof a?t:this.findNode(t),s){const t=new a(e);return t.next=s.next,s.next=t,s===this.tail&&(this.tail=t),this._length++,!0}return!1}countOccurrences(t){let e=0,s=this.head;for(;s;)s.val===t&&e++,s=s.next;return e}*[Symbol.iterator](){let t=this.head;for(;t;)yield t.val,t=t.next}}class c{constructor(t){this._val=t,this._next=null,this._prev=null}get val(){return this._val}set val(t){this._val=t}get next(){return this._next}set next(t){this._next=t}get prev(){return this._prev}set prev(t){this._prev=t}}class d{constructor(){this._head=null,this._tail=null,this._length=0}get head(){return this._head}set head(t){this._head=t}get tail(){return this._tail}set tail(t){this._tail=t}get length(){return this._length}static fromArray(t){const e=new d;for(const s of t)e.push(s);return e}push(t){const e=new c(t);this.head?(e.prev=this.tail,this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),this._length++}addLast(t){this.push(t)}pop(){if(!this.tail)return;const t=this.tail;return this.head===this.tail?(this.head=null,this.tail=null):(this.tail=t.prev,this.tail.next=null),this._length--,t.val}pollLast(){return this.pop()}shift(){if(!this.head)return;const t=this.head;return this.head===this.tail?(this.head=null,this.tail=null):(this.head=t.next,this.head.prev=null),this._length--,t.val}pollFirst(){return this.shift()}unshift(t){const e=new c(t);this.head?(e.next=this.head,this.head.prev=e,this.head=e):(this.head=e,this.tail=e),this._length++}addFirst(t){this.unshift(t)}peekFirst(){var t;return null===(t=this.head)||void 0===t?void 0:t.val}peekLast(){var t;return null===(t=this.tail)||void 0===t?void 0:t.val}get size(){return this.length}getAt(t){if(t<0||t>=this.length)return;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e.val}getNodeAt(t){if(t<0||t>=this.length)return null;let e=this.head;for(let s=0;s<t;s++)e=e.next;return e}findNode(t){let e=this.head;for(;e;){if(e.val===t)return e;e=e.next}return null}insertAt(t,e){if(t<0||t>this.length)return!1;if(0===t)return this.unshift(e),!0;if(t===this.length)return this.push(e),!0;const s=new c(e),i=this.getNodeAt(t-1),r=i.next;return s.prev=i,s.next=r,i.next=s,r.prev=s,this._length++,!0}deleteAt(t){if(t<0||t>=this.length)return;if(0===t)return this.shift();if(t===this.length-1)return this.pop();const e=this.getNodeAt(t),s=e.prev,i=e.next;return s.next=i,i.prev=s,this._length--,e.val}delete(t){let e;if(e=t instanceof c?t:this.findNode(t),e){if(e===this.head)this.shift();else if(e===this.tail)this.pop();else{const t=e.prev,s=e.next;t.next=s,s.prev=t,this._length--}return!0}return!1}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.val),e=e.next;return t}isEmpty(){return 0===this.length}clear(){this._head=null,this._tail=null,this._length=0}find(t){let e=this.head;for(;e;){if(t(e.val))return e.val;e=e.next}return null}indexOf(t){let e=0,s=this.head;for(;s;){if(s.val===t)return e;e++,s=s.next}return-1}findLast(t){let e=this.tail;for(;e;){if(t(e.val))return e.val;e=e.prev}return null}toArrayReverse(){const t=[];let e=this.tail;for(;e;)t.push(e.val),e=e.prev;return t}reverse(){let t=this.head;for([this.head,this.tail]=[this.tail,this.head];t;){const e=t.next;[t.prev,t.next]=[t.next,t.prev],t=e}}forEach(t){let e=this.head,s=0;for(;e;)t(e.val,s),e=e.next,s++}map(t){const e=new d;let s=this.head;for(;s;)e.push(t(s.val)),s=s.next;return e}filter(t){const e=new d;let s=this.head;for(;s;)t(s.val)&&e.push(s.val),s=s.next;return e}reduce(t,e){let s=e,i=this.head;for(;i;)s=t(s,i.val),i=i.next;return s}insertAfter(t,e){let s;if(s=t instanceof c?t:this.findNode(t),s){const t=new c(e);return t.next=s.next,s.next&&(s.next.prev=t),t.prev=s,s.next=t,s===this.tail&&(this.tail=t),this._length++,!0}return!1}insertBefore(t,e){let s;if(s=t instanceof c?t:this.findNode(t),s){const t=new c(e);return t.prev=s.prev,s.prev&&(s.prev.next=t),t.next=s,s.prev=t,s===this.head&&(this.head=t),this._length++,!0}return!1}}class f{constructor(t,e,s){this.key=t,this.value=e,this.forward=new Array(s)}}class g{get probability(){return this._probability}set probability(t){this._probability=t}get maxLevel(){return this._maxLevel}set maxLevel(t){this._maxLevel=t}get level(){return this._level}set level(t){this._level=t}get head(){return this._head}set head(t){this._head=t}constructor(t=16,e=.5){this._head=new f(null,null,t),this._level=0,this._maxLevel=t,this._probability=e}randomLevel(){let t=1;for(;Math.random()<this.probability&&t<this.maxLevel;)t++;return t}add(t,e){const s=new f(t,e,this.randomLevel()),i=new Array(this.maxLevel).fill(this.head);let r=this.head;for(let e=this.level-1;e>=0;e--){for(;r.forward[e]&&r.forward[e].key<t;)r=r.forward[e];i[e]=r}for(let t=0;t<s.forward.length;t++)s.forward[t]=i[t].forward[t],i[t].forward[t]=s;null!==s.forward[0]&&(this.level=Math.max(this.level,s.forward.length))}get(t){let e=this.head;for(let s=this.level-1;s>=0;s--)for(;e.forward[s]&&e.forward[s].key<t;)e=e.forward[s];if(e=e.forward[0],e&&e.key===t)return e.value}delete(t){const e=new Array(this.maxLevel).fill(this.head);let s=this.head;for(let i=this.level-1;i>=0;i--){for(;s.forward[i]&&s.forward[i].key<t;)s=s.forward[i];e[i]=s}if(s=s.forward[0],s&&s.key===t){for(let t=0;t<this.level&&e[t].forward[t]===s;t++)e[t].forward[t]=s.forward[t];for(;this.level>0&&null===this.head.forward[this.level-1];)this.level--;return!0}return!1}}class _{constructor(t){this._elements=Array.isArray(t)?t:[]}static fromArray(t){return new _(t)}isEmpty(){return 0===this._elements.length}size(){return this._elements.length}peek(){return this.isEmpty()?null:this._elements[this._elements.length-1]}push(t){return this._elements.push(t),this}pop(){return this.isEmpty()?null:this._elements.pop()||null}toArray(){return this._elements.slice()}clear(){this._elements=[]}clone(){return new _(this._elements.slice())}}class p extends u{enqueue(t){this.push(t)}dequeue(){return this.shift()}peek(){var t;return null===(t=this.head)||void 0===t?void 0:t.val}}class v{constructor(t){this._nodes=t||[],this._offset=0}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get offset(){return this._offset}set offset(t){this._offset=t}get size(){return this.nodes.length-this.offset}static fromArray(t){return new v(t)}push(t){return this.nodes.push(t),this}shift(){if(0===this.size)return;const t=this.peek();return this.offset+=1,2*this.offset<this.nodes.length||(this.nodes=this.nodes.slice(this.offset),this.offset=0),t}peek(){return this.size>0?this.nodes[this.offset]:void 0}peekLast(){return this.size>0?this.nodes[this.nodes.length-1]:void 0}enqueue(t){this.push(t)}dequeue(){return this.shift()}getAt(t){return this.nodes[t]}isEmpty(){return 0===this.size}toArray(){return this.nodes.slice(this.offset)}clear(){this.nodes=[],this.offset=0}clone(){return new v(this.nodes.slice(this.offset))}*[Symbol.iterator](){for(const t of this.nodes)yield t}}class y extends d{}class m{constructor(t){this._nodes={},this._capacity=Number.MAX_SAFE_INTEGER,this._first=-1,this._last=-1,this._size=0,void 0!==t&&(this._capacity=t)}get nodes(){return this._nodes}get capacity(){return this._capacity}set capacity(t){this._capacity=t}get first(){return this._first}set first(t){this._first=t}get last(){return this._last}set last(t){this._last=t}get size(){return this._size}addFirst(t){if(0===this._size){const t=Math.floor(this._capacity/2);this._first=t,this._last=t}else this._first--;this._nodes[this._first]=t,this._size++}addLast(t){if(0===this._size){const t=Math.floor(this._capacity/2);this._first=t,this._last=t}else this._last++;this._nodes[this._last]=t,this._size++}pollFirst(){if(!this._size)return;const t=this.peekFirst();return delete this._nodes[this._first],this._first++,this._size--,t}peekFirst(){if(this._size)return this._nodes[this._first]}pollLast(){if(!this._size)return;const t=this.peekLast();return delete this._nodes[this._last],this._last--,this._size--,t}peekLast(){if(this._size)return this._nodes[this._last]}get(t){return this._nodes[this._first+t]||null}isEmpty(){return this._size<=0}_seNodes(t){this._nodes=t}_setSize(t){this._size=t}}class x{constructor(){this._nodes=[]}get size(){return this._nodes.length}addLast(t){return this._nodes.push(t)}pollLast(){var t;return null!==(t=this._nodes.pop())&&void 0!==t?t:null}pollFirst(){var t;return null!==(t=this._nodes.shift())&&void 0!==t?t:null}addFirst(t){return this._nodes.unshift(t)}peekFirst(){var t;return null!==(t=this._nodes[0])&&void 0!==t?t:null}peekLast(){var t;return null!==(t=this._nodes[this._nodes.length-1])&&void 0!==t?t:null}get(t){var e;return null!==(e=this._nodes[t])&&void 0!==e?e:null}set(t,e){return this._nodes[t]=e}insert(t,e){return this._nodes.splice(t,0,e)}delete(t){return this._nodes.splice(t,1)}isEmpty(){return 0===this._nodes.length}}const b=function(){return"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/[x]/g,(function(t){const e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},E=function(t,e){let s=-1,i=t?t.length:0;const r=[];for(;++s<i;){const n=t[s];e(n,s,t)&&(r.push(n),Array.prototype.splice.call(t,s--,1),i--)}return r},w=Symbol("thunk"),k=t=>"function"==typeof t&&t.__THUNK__===w,M=t=>{const e=()=>t();return e.__THUNK__=w,e},T=t=>Object.assign(((...e)=>{let s=t(...e);for(;k(s)&&"function"==typeof s;)s=s();return s}),{cont:(...e)=>M((()=>t(...e)))}),S=t=>Object.assign(((...e)=>{return s=void 0,i=void 0,n=function*(){let s=yield t(...e);for(;k(s)&&"function"==typeof s;)s=yield s();return s},new((r=void 0)||(r=Promise))((function(t,e){function h(t){try{l(n.next(t))}catch(t){e(t)}}function o(t){try{l(n.throw(t))}catch(t){e(t)}}function l(e){var s;e.done?t(e.value):(s=e.value,s instanceof r?s:new r((function(t){t(s)}))).then(h,o)}l((n=n.apply(s,i||[])).next())}));var s,i,r,n}),{cont:(...e)=>M((()=>t(...e)))}),R=t=>t<=0?0:1<<31-Math.clz32(t);class z{constructor(t){this.nodes=[],this.comparator=t}add(t){return this.push(t)}push(t){return this.nodes.push(t),this.bubbleUp(this.nodes.length-1),this}poll(){if(0===this.nodes.length)return;if(1===this.nodes.length)return this.nodes.pop();const t=this.nodes[0];return this.nodes[0]=this.nodes.pop(),this.sinkDown(0),t}pop(){return this.poll()}bubbleUp(t){const e=this.nodes[t];for(;t>0;){const s=Math.floor((t-1)/2),i=this.nodes[s];if(!(this.comparator(e,i)<0))break;this.nodes[t]=i,this.nodes[s]=e,t=s}}sinkDown(t){const e=2*t+1,s=2*t+2,i=this.nodes.length;let r=t;if(e<i&&this.comparator(this.nodes[e],this.nodes[r])<0&&(r=e),s<i&&this.comparator(this.nodes[s],this.nodes[r])<0&&(r=s),r!==t){const e=this.nodes[t];this.nodes[t]=this.nodes[r],this.nodes[r]=e,this.sinkDown(r)}}fix(){for(let t=Math.floor(this.size/2);t>=0;t--)this.sinkDown(t)}peek(){if(0!==this.nodes.length)return this.nodes[0]}get size(){return this.nodes.length}get leaf(){var t;return null!==(t=this.nodes[this.size-1])&&void 0!==t?t:void 0}isEmpty(){return 0===this.size}clear(){this.nodes=[]}refill(t){this.nodes=t,this.fix()}has(t){return this.nodes.includes(t)}dfs(t){const e=[],s=i=>{i<this.size&&("in"===t?(s(2*i+1),e.push(this.nodes[i]),s(2*i+2)):"pre"===t?(e.push(this.nodes[i]),s(2*i+1),s(2*i+2)):"post"===t&&(s(2*i+1),s(2*i+2),e.push(this.nodes[i])))};return s(0),e}toArray(){return[...this.nodes]}getNodes(){return this.nodes}clone(){const t=new z(this.comparator);return t.nodes=[...this.nodes],t}sort(){const t=[],e=this.clone();for(;0!==e.size;){const s=e.poll();s&&t.push(s)}return t}static heapify(t,e){const s=new z(e);return s.nodes=[...t],s.fix(),s}}class V{constructor(t,e=0){this.element=t,this.degree=e,this.marked=!1}}class C{constructor(t){if(this.size=0,this.clear(),this.comparator=t||this.defaultComparator,"function"!=typeof this.comparator)throw new Error("FibonacciHeap constructor: given comparator should be a function.")}defaultComparator(t,e){return t<e?-1:t>e?1:0}clear(){this.root=void 0,this.min=void 0,this.size=0}createNode(t){return new V(t)}mergeWithRoot(t){this.root?(t.right=this.root.right,t.left=this.root,this.root.right.left=t,this.root.right=t):this.root=t}add(t){return this.push(t)}push(t){const e=this.createNode(t);return e.left=e,e.right=e,this.mergeWithRoot(e),(!this.min||this.comparator(e.element,this.min.element)<=0)&&(this.min=e),this.size++,this}peek(){return this.min?this.min.element:void 0}consumeLinkedList(t){const e=[];if(!t)return e;let s=t,i=!1;for(;s!==t||!i;)s===t&&(i=!0),s&&(e.push(s),s=s.right);return e}removeFromRoot(t){this.root===t&&(this.root=t.right),t.left&&(t.left.right=t.right),t.right&&(t.right.left=t.left)}mergeWithChild(t,e){t.child?(e.right=t.child.right,e.left=t.child,t.child.right.left=e,t.child.right=e):t.child=e}link(t,e){this.removeFromRoot(t),t.left=t,t.right=t,this.mergeWithChild(e,t),e.degree++,t.parent=e}consolidate(){const t=new Array(this.size),e=this.consumeLinkedList(this.root);let s,i,r,n;for(const h of e){for(s=h,r=s.degree;t[r];)i=t[r],this.comparator(s.element,i.element)>0&&(n=s,s=i,i=n),this.link(i,s),t[r]=void 0,r++;t[r]=s}for(let e=0;e<this.size;e++)t[e]&&this.comparator(t[e].element,this.min.element)<=0&&(this.min=t[e])}poll(){return this.pop()}pop(){if(0===this.size)return;const t=this.min;if(t.child){const e=this.consumeLinkedList(t.child);for(const t of e)this.mergeWithRoot(t),t.parent=void 0}return this.removeFromRoot(t),t===t.right?(this.min=void 0,this.root=void 0):(this.min=t.right,this.consolidate()),this.size--,t.element}merge(t){if(0!==t.size){if(this.root&&t.root){const e=this.root,s=t.root,i=e.right,r=s.left;e.right=s,s.left=e,i.left=r,r.right=i}(!this.min||t.min&&this.comparator(t.min.element,this.min.element)<0)&&(this.min=t.min),this.size+=t.size,t.clear()}}}class A extends z{constructor(t){super(t)}}class N{constructor(t,e){this._key=t,this._val=e}get key(){return this._key}set key(t){this._key=t}get val(){return this._val}set val(t){this._val=t}}class O{constructor(t,e){this._weight=void 0!==t?t:1,this._val=e,this._hashCode=b()}get val(){return this._val}set val(t){this._val=t}get weight(){return this._weight}set weight(t){this._weight=t}get hashCode(){return this._hashCode}_setHashCode(t){this._hashCode=t}}class L{constructor(){this._vertices=new Map}get vertices(){return this._vertices}getVertex(t){return this._vertices.get(t)||null}hasVertex(t){return this._vertices.has(this._getVertexKey(t))}addVertex(t,e){if(t instanceof N)return this._addVertexOnly(t);{const s=this.createVertex(t,e);return this._addVertexOnly(s)}}removeVertex(t){const e=this._getVertexKey(t);return this._vertices.delete(e)}removeAllVertices(t){const e=[];for(const s of t)e.push(this.removeVertex(s));return e.length>0}hasEdge(t,e){return!!this.getEdge(t,e)}addEdge(t,e,s,i){if(t instanceof O)return this._addEdgeOnly(t);if(e instanceof N||"string"==typeof e||"number"==typeof e){if(!this.hasVertex(t)||!this.hasVertex(e))return!1;t instanceof N&&(t=t.key),e instanceof N&&(e=e.key);const r=this.createEdge(t,e,s,i);return this._addEdgeOnly(r)}throw new Error("dest must be a Vertex or vertex key while srcOrEdge is an Edge")}setEdgeWeight(t,e,s){const i=this.getEdge(t,e);return!!i&&(i.weight=s,!0)}getAllPathsBetween(t,e){const s=[],i=this._getVertex(t),r=this._getVertex(e);if(!i||!r)return[];const n=(t,e,r,h)=>{r.set(t,!0),t===e&&s.push([i,...h]);const o=this.getNeighbors(t);for(const t of o)r.get(t)||(h.push(t),n(t,e,r,h),E(h,(e=>e===t)));r.set(t,!1)};return n(i,r,new Map,[]),s}getPathSumWeight(t){var e;let s=0;for(let i=0;i<t.length;i++)s+=(null===(e=this.getEdge(t[i],t[i+1]))||void 0===e?void 0:e.weight)||0;return s}getMinCostBetween(t,e,s){if(void 0===s&&(s=!1),s){const s=this.getAllPathsBetween(t,e);let i=1/0;for(const t of s)i=Math.min(this.getPathSumWeight(t),i);return i}{const s=this._getVertex(e),i=this._getVertex(t);if(!i||!s)return null;const r=new Map,n=new v([i]);r.set(i,!0);let h=0;for(;n.size>0;){for(let t=0;t<n.size;t++){const t=n.shift();if(t===s)return h;if(void 0!==t){const e=this.getNeighbors(t);for(const t of e)r.has(t)||(r.set(t,!0),n.push(t))}}h++}return null}}getMinPathBetween(t,e,s){if(void 0===s&&(s=!1),s){const s=this.getAllPathsBetween(t,e);let i=1/0,r=-1,n=0;for(const t of s){const e=this.getPathSumWeight(t);e<i&&(i=e,r=n),n++}return s[r]||null}{let s=[];const i=this._getVertex(t),r=this._getVertex(e);if(!i||!r)return[];const n=(t,e,r,h)=>{if(r.set(t,!0),t===e)return void(s=[i,...h]);const o=this.getNeighbors(t);for(const t of o)r.get(t)||(h.push(t),n(t,e,r,h),E(h,(e=>e===t)));r.set(t,!1)};return n(i,r,new Map,[]),s}}dijkstraWithoutHeap(t,e,s,i){void 0===s&&(s=!1),void 0===i&&(i=!1),void 0===e&&(e=null);let r=1/0,n=null,h=[];const o=[],l=this._vertices,a=new Map,u=new Set,c=new Map,d=this._getVertex(t),f=e?this._getVertex(e):null;if(!d)return null;for(const t of l){const e=t[1];e instanceof N&&a.set(e,1/0)}a.set(d,0),c.set(d,null);const g=()=>{let t=1/0,e=null;for(const[s,i]of a)u.has(s)||i<t&&(t=i,e=s);return e},_=t=>{for(const e of l){const s=e[1];if(s instanceof N){const i=[s];let r=c.get(s);for(;r;)i.push(r),r=c.get(r);const n=i.reverse();e[1]===t&&(h=n),o.push(n)}}};for(let t=1;t<l.size;t++){const t=g();if(t){if(u.add(t),f&&f===t)return s&&(r=a.get(f)||1/0),i&&_(f),{distMap:a,preMap:c,seen:u,paths:o,minDist:r,minPath:h};const e=this.getNeighbors(t);for(const s of e)if(!u.has(s)){const e=this.getEdge(t,s);if(e){const i=a.get(t),r=a.get(s);void 0!==i&&void 0!==r&&e.weight+i<r&&(a.set(s,e.weight+i),c.set(s,t))}}}}return s&&a.forEach(((t,e)=>{e!==d&&t<r&&(r=t,i&&(n=e))})),i&&_(n),{distMap:a,preMap:c,seen:u,paths:o,minDist:r,minPath:h}}dijkstra(t,e,s,i){var r;void 0===s&&(s=!1),void 0===i&&(i=!1),void 0===e&&(e=null);let n=1/0,h=null,o=[];const l=[],a=this._vertices,u=new Map,c=new Set,d=new Map,f=this._getVertex(t),g=e?this._getVertex(e):null;if(!f)return null;for(const t of a){const e=t[1];e instanceof N&&u.set(e,1/0)}const _=new A(((t,e)=>t.key-e.key));_.add({key:0,val:f}),u.set(f,0),d.set(f,null);const p=t=>{for(const e of a){const s=e[1];if(s instanceof N){const i=[s];let r=d.get(s);for(;r;)i.push(r),r=d.get(r);const n=i.reverse();e[1]===t&&(o=n),l.push(n)}}};for(;_.size>0;){const t=_.poll(),e=null==t?void 0:t.key,h=null==t?void 0:t.val;if(void 0!==e&&h){if(c.add(h),g&&g===h)return s&&(n=u.get(g)||1/0),i&&p(g),{distMap:u,preMap:d,seen:c,paths:l,minDist:n,minPath:o};const t=this.getNeighbors(h);for(const s of t)if(!c.has(s)){const t=null===(r=this.getEdge(h,s))||void 0===r?void 0:r.weight;if("number"==typeof t){const i=u.get(s);i&&e+t<i&&(_.add({key:e+t,val:s}),d.set(s,h),u.set(s,e+t))}}}}return s&&u.forEach(((t,e)=>{e!==f&&t<n&&(n=t,i&&(h=e))})),i&&p(h),{distMap:u,preMap:d,seen:c,paths:l,minDist:n,minPath:o}}bellmanFord(t,e,s,i){void 0===s&&(s=!1),void 0===i&&(i=!1);const r=this._getVertex(t),n=[],h=new Map,o=new Map;let l,a=1/0,u=[];if(e&&(l=!1),!r)return{hasNegativeCycle:l,distMap:h,preMap:o,paths:n,min:a,minPath:u};const c=this._vertices,d=c.size,f=this.edgeSet(),g=f.length;this._vertices.forEach((t=>{h.set(t,1/0)})),h.set(r,0);for(let t=1;t<d;++t)for(let t=0;t<g;++t){const e=this.getEndsOfEdge(f[t]);if(e){const[s,r]=e,n=f[t].weight,l=h.get(s),a=h.get(r);void 0!==l&&void 0!==a&&h.get(s)!==1/0&&l+n<a&&(h.set(r,l+n),i&&o.set(r,s))}}let _=null;if(s&&h.forEach(((t,e)=>{e!==r&&t<a&&(a=t,i&&(_=e))})),i)for(const t of c){const e=t[1];if(e instanceof N){const s=[e];let i=o.get(e);for(;void 0!==i;)s.push(i),i=o.get(i);const r=s.reverse();t[1]===_&&(u=r),n.push(r)}}for(let t=0;t<g;++t){const e=this.getEndsOfEdge(f[t]);if(e){const[s]=e,i=f[t].weight,r=h.get(s);r&&r!==1/0&&r+i<r&&(l=!0)}}return{hasNegativeCycle:l,distMap:h,preMap:o,paths:n,min:a,minPath:u}}floyd(){var t;const e=[...this._vertices],s=e.length,i=[],r=[];for(let t=0;t<s;t++){i[t]=[],r[t]=[];for(let e=0;e<s;e++)r[t][e]=null}for(let r=0;r<s;r++)for(let n=0;n<s;n++)i[r][n]=(null===(t=this.getEdge(e[r][1],e[n][1]))||void 0===t?void 0:t.weight)||1/0;for(let t=0;t<s;t++)for(let n=0;n<s;n++)for(let h=0;h<s;h++)i[n][h]>i[n][t]+i[t][h]&&(i[n][h]=i[n][t]+i[t][h],r[n][h]=e[t][1]);return{costs:i,predecessor:r}}tarjan(t,e,s,i){const r=!1;void 0===t&&(t=r),void 0===e&&(e=r),void 0===s&&(s=r),void 0===i&&(i=r);const n=new Map,h=new Map,o=this._vertices;o.forEach((t=>{n.set(t,-1),h.set(t,1/0)}));const[l]=o.values(),a=[],u=[];let c=0;const d=(s,i)=>{c++,n.set(s,c),h.set(s,c);const r=this.getNeighbors(s);let o=0;for(const c of r)if(c!==i){-1===n.get(c)&&(o++,d(c,s));const i=h.get(c),r=h.get(s);void 0!==r&&void 0!==i&&h.set(s,Math.min(r,i));const f=n.get(s);if(void 0!==i&&void 0!==f&&(t&&(s===l&&o>=2||s!==l&&i>=f)&&a.push(s),e&&i>f)){const t=this.getEdge(s,c);t&&u.push(t)}}};d(l,null);let f=new Map;const g=()=>{const t=new Map;return h.forEach(((e,s)=>{var i;t.has(e)?null===(i=t.get(e))||void 0===i||i.push(s):t.set(e,[s])})),t};s&&(f=g());const _=new Map;if(i){let t=new Map;t.size<1&&(t=g()),t.forEach(((t,e)=>{t.length>1&&_.set(e,t)}))}return{dfnMap:n,lowMap:h,bridges:u,articulationPoints:a,SCCs:f,cycles:_}}_addVertexOnly(t){return!this.hasVertex(t)&&(this._vertices.set(t.key,t),!0)}_getVertex(t){const e=this._getVertexKey(t);return this._vertices.get(e)||null}_getVertexKey(t){return t instanceof N?t.key:t}_setVertices(t){this._vertices=t}}class I extends N{constructor(t,e){super(t,e)}}class F extends O{constructor(t,e,s,i){super(s,i),this._src=t,this._dest=e}get src(){return this._src}set src(t){this._src=t}get dest(){return this._dest}set dest(t){this._dest=t}}class P extends L{constructor(){super(),this._outEdgeMap=new Map,this._inEdgeMap=new Map}get outEdgeMap(){return this._outEdgeMap}get inEdgeMap(){return this._inEdgeMap}createVertex(t,e){return new I(t,null!=e?e:t)}createEdge(t,e,s,i){return new F(t,e,null!=s?s:1,i)}getEdge(t,e){let s=[];if(null!==t&&null!==e){const i=this._getVertex(t),r=this._getVertex(e);if(i&&r){const t=this._outEdgeMap.get(i);t&&(s=t.filter((t=>t.dest===r.key)))}}return s[0]||null}removeEdgeSrcToDest(t,e){const s=this._getVertex(t),i=this._getVertex(e);let r=null;if(!s||!i)return null;const n=this._outEdgeMap.get(s);n&&E(n,(t=>t.dest===i.key));const h=this._inEdgeMap.get(i);return h&&(r=E(h,(t=>t.src===s.key))[0]||null),r}removeEdge(t){let e=null;const s=this._getVertex(t.src),i=this._getVertex(t.dest);if(s&&i){const t=this._outEdgeMap.get(s);t&&t.length>0&&E(t,(t=>t.src===s.key));const r=this._inEdgeMap.get(i);r&&r.length>0&&(e=E(r,(t=>t.dest===i.key))[0])}return e}removeEdgesBetween(t,e){const s=[];if(t&&e){const i=this.removeEdgeSrcToDest(t,e),r=this.removeEdgeSrcToDest(e,t);i&&s.push(i),r&&s.push(r)}return s}incomingEdgesOf(t){const e=this._getVertex(t);return e&&this.inEdgeMap.get(e)||[]}outgoingEdgesOf(t){const e=this._getVertex(t);return e&&this._outEdgeMap.get(e)||[]}degreeOf(t){return this.outDegreeOf(t)+this.inDegreeOf(t)}inDegreeOf(t){return this.incomingEdgesOf(t).length}outDegreeOf(t){return this.outgoingEdgesOf(t).length}edgesOf(t){return[...this.outgoingEdgesOf(t),...this.incomingEdgesOf(t)]}getEdgeSrc(t){return this._getVertex(t.src)}getEdgeDest(t){return this._getVertex(t.dest)}getDestinations(t){if(null===t)return[];const e=[],s=this.outgoingEdgesOf(t);for(const t of s){const s=this.getEdgeDest(t);s&&e.push(s)}return e}topologicalSort(t){t=null!=t?t:"key";const e=new Map;for(const t of this.vertices)e.set(t[1],0);let s=[],i=!1;const r=t=>{e.set(t,1);const n=this.getDestinations(t);for(const t of n){const s=e.get(t);0===s?r(t):1===s&&(i=!0)}e.set(t,2),s.push(t)};for(const t of this.vertices)0===e.get(t[1])&&r(t[1]);return i?null:("key"===t&&(s=s.map((t=>t instanceof I?t.key:t))),s.reverse())}edgeSet(){let t=[];return this._outEdgeMap.forEach((e=>{t=[...t,...e]})),t}getNeighbors(t){const e=[],s=this._getVertex(t);if(s){const t=this.outgoingEdgesOf(s);for(const s of t){const t=this._getVertex(s.dest);t&&e.push(t)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.src,t.dest))return null;const e=this._getVertex(t.src),s=this._getVertex(t.dest);return e&&s?[e,s]:null}_addEdgeOnly(t){if(!this.hasVertex(t.src)||!this.hasVertex(t.dest))return!1;const e=this._getVertex(t.src),s=this._getVertex(t.dest);if(e&&s){const i=this._outEdgeMap.get(e);i?i.push(t):this._outEdgeMap.set(e,[t]);const r=this._inEdgeMap.get(s);return r?r.push(t):this._inEdgeMap.set(s,[t]),!0}return!1}_setOutEdgeMap(t){this._outEdgeMap=t}_setInEdgeMap(t){this._inEdgeMap=t}}class D extends N{constructor(t,e){super(t,e)}}class B extends O{constructor(t,e,s,i){super(s,i),this._vertices=[t,e]}get vertices(){return this._vertices}set vertices(t){this._vertices=t}}class H extends L{constructor(){super(),this._edges=new Map}get edges(){return this._edges}createVertex(t,e){return new D(t,null!=e?e:t)}createEdge(t,e,s,i){return new B(t,e,null!=s?s:1,i)}getEdge(t,e){var s;let i=[];if(null!==t&&null!==e){const r=this._getVertex(t),n=this._getVertex(e);r&&n&&(i=null===(s=this._edges.get(r))||void 0===s?void 0:s.filter((t=>t.vertices.includes(n.key))))}return i&&i[0]||null}removeEdgeBetween(t,e){const s=this._getVertex(t),i=this._getVertex(e);if(!s||!i)return null;const r=this._edges.get(s);let n=null;r&&(n=E(r,(t=>t.vertices.includes(i.key)))[0]||null);const h=this._edges.get(i);return h&&E(h,(t=>t.vertices.includes(s.key))),n}removeEdge(t){return this.removeEdgeBetween(t.vertices[0],t.vertices[1])}degreeOf(t){var e;const s=this._getVertex(t);return s&&(null===(e=this._edges.get(s))||void 0===e?void 0:e.length)||0}edgesOf(t){const e=this._getVertex(t);return e&&this._edges.get(e)||[]}edgeSet(){const t=new Set;return this._edges.forEach((e=>{e.forEach((e=>{t.add(e)}))})),[...t]}getNeighbors(t){const e=[],s=this._getVertex(t);if(s){const t=this.edgesOf(s);for(const i of t){const t=this._getVertex(i.vertices.filter((t=>t!==s.key))[0]);t&&e.push(t)}}return e}getEndsOfEdge(t){if(!this.hasEdge(t.vertices[0],t.vertices[1]))return null;const e=this._getVertex(t.vertices[0]),s=this._getVertex(t.vertices[1]);return e&&s?[e,s]:null}_addEdgeOnly(t){for(const e of t.vertices){const s=this._getVertex(e);if(null===s)return!1;if(s){const e=this._edges.get(s);e?e.push(t):this._edges.set(s,[t])}}return!0}_setEdges(t){this._edges=t}}class q extends I{constructor(t,e,s,i){super(t,i),this._lat=e,this._long=s}get lat(){return this._lat}set lat(t){this._lat=t}get long(){return this._long}set long(t){this._long=t}}class j extends F{constructor(t,e,s,i){super(t,e,s,i)}}class U extends P{constructor(t,e){super(),this._origin=[0,0],this._origin=t,this._bottomRight=e}get origin(){return this._origin}set origin(t){this._origin=t}get bottomRight(){return this._bottomRight}set bottomRight(t){this._bottomRight=t}createVertex(t,e,s=this.origin[0],i=this.origin[1]){return new q(t,s,i,e)}createEdge(t,e,s,i){return new j(t,e,s,i)}}var K,G,W,Q,Y;!function(t){t.ITERATIVE="ITERATIVE",t.RECURSIVE="RECURSIVE"}(K||(K={})),function(t){t.ROOT="ROOT",t.LEFT="LEFT",t.RIGHT="RIGHT",t.ROOT_LEFT="ROOT_LEFT",t.ROOT_RIGHT="ROOT_RIGHT",t.ISOLATED="ISOLATED",t.MAL_NODE="MAL_NODE"}(G||(G={})),function(t){t.RED="RED",t.BLACK="BLACK"}(W||(W={})),function(t){t.VAL="VAL",t.NODE="NODE",t.ID="ID"}(Q||(Q={})),function(t){t.lt="lt",t.eq="eq",t.gt="gt"}(Y||(Y={}));class J{constructor(t,e){this.key=t,this.val=e}get left(){return this._left}set left(t){t&&(t.parent=this),this._left=t}get right(){return this._right}set right(t){t&&(t.parent=this),this._right=t}get familyPosition(){const t=this;return t.parent?t.parent.left===t?t.left||t.right?G.ROOT_LEFT:G.LEFT:t.parent.right===t?t.left||t.right?G.ROOT_RIGHT:G.RIGHT:G.MAL_NODE:t.left||t.right?G.ROOT:G.ISOLATED}}class X{constructor(t){if(this._root=null,this._size=0,this._loopType=K.ITERATIVE,this._defaultCallbackByKey=t=>t.key,void 0!==t){const{iterationType:e=K.ITERATIVE}=t;this._loopType=e}}createNode(t,e){return new J(t,e)}get root(){return this._root}get size(){return this._size}get iterationType(){return this._loopType}set iterationType(t){this._loopType=t}_swap(t,e){const{key:s,val:i}=e,r=this.createNode(s,i);return r&&(e.key=t.key,e.val=t.val,t.key=r.key,t.val=r.val),e}clear(){this._root=null,this._size=0}isEmpty(){return 0===this.size}add(t,e){let s,i;if(null===t)i=null;else if("number"==typeof t)i=this.createNode(t,e);else{if(!(t instanceof J))return;i=t}const r=t?this.get(t,this._defaultCallbackByKey):void 0;return this.root?r?(r.val=e,s=r):s=((t,e)=>{const s=new v([t]);for(;s.size>0;){const t=s.shift();if(!t)return;{if(e&&t.key===e.key)return;const i=this._addTo(e,t);if(void 0!==i)return i;t.left&&s.push(t.left),t.right&&s.push(t.right)}}})(this.root,i):(this._setRoot(i),null!==i?this._setSize(1):this._setSize(0),s=this.root),s}addMany(t,e){const s=[];for(let i=0;i<t.length;i++){const r=t[i];if(r instanceof J){s.push(this.add(r.key,r.val));continue}if(null===r){s.push(this.add(null));continue}const n=null==e?void 0:e[i];s.push(this.add(r,n))}return s}refill(t,e){return this.clear(),t.length===this.addMany(t,e).length}delete(t){const e=[];if(!this.root)return e;const s="number"==typeof t?this.get(t):t;if(!s)return e;const i=(null==s?void 0:s.parent)?s.parent:null;let r=null,n=s;if(s.left){const t=s.left?this.getRightMost(s.left):null;if(t){const e=t.parent;n=this._swap(s,t),e&&(e.right===t?e.right=t.left:e.left=t.left,r=e)}}else if(i){const{familyPosition:t}=s;t===G.LEFT||t===G.ROOT_LEFT?i.left=s.right:t!==G.RIGHT&&t!==G.ROOT_RIGHT||(i.right=s.right),r=i}else void 0!==s.right&&this._setRoot(s.right);return this._setSize(this.size-1),e.push({deleted:n,needBalanced:r}),e}getDepth(t,e=this.root){"number"==typeof t&&(t=this.get(t)),"number"==typeof e&&(e=this.get(e));let s=0;for(;null==t?void 0:t.parent;){if(t===e)return s;s++,t=t.parent}return s}getHeight(t=this.root,e=this.iterationType){if("number"==typeof t&&(t=this.get(t)),!t)return-1;if(e===K.RECURSIVE){const e=t=>{if(!t)return-1;const s=e(t.left),i=e(t.right);return Math.max(s,i)+1};return e(t)}{if(!t)return-1;const e=[{node:t,depth:0}];let s=0;for(;e.length>0;){const{node:t,depth:i}=e.pop();t.left&&e.push({node:t.left,depth:i+1}),t.right&&e.push({node:t.right,depth:i+1}),s=Math.max(s,i)}return s}}getMinHeight(t=this.root,e=this.iterationType){var s,i,r;if(!t)return-1;if(e===K.RECURSIVE){const e=t=>{if(!t)return 0;if(!t.left&&!t.right)return 0;const s=e(t.left),i=e(t.right);return Math.min(s,i)+1};return e(t)}{const e=[];let n=t,h=null;const o=new Map;for(;e.length>0||n;)if(n)e.push(n),n=n.left;else if(n=e[e.length-1],n.right&&h!==n.right)n=n.right;else if(n=e.pop(),n){const t=n.left&&null!==(s=o.get(n.left))&&void 0!==s?s:-1,e=n.right&&null!==(i=o.get(n.right))&&void 0!==i?i:-1;o.set(n,1+Math.min(t,e)),h=n,n=null}return null!==(r=o.get(t))&&void 0!==r?r:-1}}isPerfectlyBalanced(t=this.root){return this.getMinHeight(t)+1>=this.getHeight(t)}getNodes(t,e=this._defaultCallbackByKey,s=!1,i=this.root,r=this.iterationType){if(!i)return[];const n=[];if(r===K.RECURSIVE){const r=i=>{e(i)===t&&(n.push(i),s)||(i.left||i.right)&&(i.left&&r(i.left),i.right&&r(i.right))};r(i)}else{const r=new v([i]);for(;r.size>0;){const i=r.shift();if(i){if(e(i)===t&&(n.push(i),s))return n;i.left&&r.push(i.left),i.right&&r.push(i.right)}}}return n}has(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){return this.getNodes(t,e,!0,s,i).length>0}get(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){var r;return null!==(r=this.getNodes(t,e,!0,s,i)[0])&&void 0!==r?r:null}getPathToRoot(t,e=!0){const s=[];for(;t.parent;)s.push(t),t=t.parent;return s.push(t),e?s.reverse():s}getLeftMost(t=this.root,e=this.iterationType){if("number"==typeof t&&(t=this.get(t)),!t)return t;if(e===K.RECURSIVE){const e=t=>t.left?e(t.left):t;return e(t)}{const e=T((t=>t.left?e.cont(t.left):t));return e(t)}}getRightMost(t=this.root,e=this.iterationType){if(!t)return t;if(e===K.RECURSIVE){const e=t=>t.right?e(t.right):t;return e(t)}{const e=T((t=>t.right?e.cont(t.right):t));return e(t)}}isSubtreeBST(t,e=this.iterationType){if(!t)return!0;if(e===K.RECURSIVE){const e=(t,s,i)=>!t||!(t.key<=s||t.key>=i)&&e(t.left,s,t.key)&&e(t.right,t.key,i);return e(t,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)}{const e=[];let s=Number.MIN_SAFE_INTEGER,i=t;for(;i||e.length>0;){for(;i;)e.push(i),i=i.left;if(i=e.pop(),!i||s>=i.key)return!1;s=i.key,i=i.right}return!0}}isBST(t=this.iterationType){return null===this.root||this.isSubtreeBST(this.root,t)}subTreeTraverse(t=this._defaultCallbackByKey,e=this.root,s=this.iterationType){"number"==typeof e&&(e=this.get(e));const i=[];if(!e)return i;if(s===K.RECURSIVE){const s=e=>{i.push(t(e)),e.left&&s(e.left),e.right&&s(e.right)};s(e)}else{const s=[e];for(;s.length>0;){const e=s.pop();i.push(t(e)),e.right&&s.push(e.right),e.left&&s.push(e.left)}}return i}dfs(t=this._defaultCallbackByKey,e="in",s=this.root,i=K.ITERATIVE){if(!s)return[];const r=[];if(i===K.RECURSIVE){const i=s=>{switch(e){case"in":s.left&&i(s.left),r.push(t(s)),s.right&&i(s.right);break;case"pre":r.push(t(s)),s.left&&i(s.left),s.right&&i(s.right);break;case"post":s.left&&i(s.left),s.right&&i(s.right),r.push(t(s))}};i(s)}else{const i=[{opt:0,node:s}];for(;i.length>0;){const s=i.pop();if(s&&s.node)if(1===s.opt)r.push(t(s.node));else switch(e){case"in":default:i.push({opt:0,node:s.node.right}),i.push({opt:1,node:s.node}),i.push({opt:0,node:s.node.left});break;case"pre":i.push({opt:0,node:s.node.right}),i.push({opt:0,node:s.node.left}),i.push({opt:1,node:s.node});break;case"post":i.push({opt:1,node:s.node}),i.push({opt:0,node:s.node.right}),i.push({opt:0,node:s.node.left})}}}return r}bfs(t=this._defaultCallbackByKey,e=!1,s=this.root,i=this.iterationType){if(!s)return[];const r=[];if(i===K.RECURSIVE){const i=(s,n)=>{t&&r.push(t(s,e?n:void 0)),s.left&&i(s.left,n+1),s.right&&i(s.right,n+1)};i(s,0)}else{const i=[[s,0]];for(;i.length>0;){const s=i.pop(),[n,h]=s;t&&r.push(t(n,e?h:void 0)),n.right&&i.push([n.right,h+1]),n.left&&i.push([n.left,h+1])}}return r}getPredecessor(t){if(t.left){let e=t.left;for(;!e||e.right&&e.right!==t;)e&&(e=e.right);return e}return t}morris(t=this._defaultCallbackByKey,e="in",s=this.root){if(null===s)return[];const i=[];let r=s;const n=t=>{let e=null,s=null;for(;t;)s=t.right,t.right=e,e=t,t=s;return e},h=e=>{const s=n(e);let r=s;for(;r;)i.push(t(r)),r=r.right;n(s)};switch(e){case"in":for(;r;){if(r.left){const t=this.getPredecessor(r);if(!t.right){t.right=r,r=r.left;continue}t.right=null}i.push(t(r)),r=r.right}break;case"pre":for(;r;){if(r.left){const e=this.getPredecessor(r);if(!e.right){e.right=r,i.push(t(r)),r=r.left;continue}e.right=null}else i.push(t(r));r=r.right}break;case"post":for(;r;){if(r.left){const t=this.getPredecessor(r);if(null===t.right){t.right=r,r=r.left;continue}t.right=null,h(r.left)}r=r.right}h(s)}return i}_addTo(t,e){return e?void 0===e.left?(e.left=t,t&&this._setSize(this.size+1),e.left):void 0===e.right?(e.right=t,t&&this._setSize(this.size+1),e.right):void 0:void 0}_setRoot(t){t&&(t.parent=void 0),this._root=t}_setSize(t){this._size=t}}class Z extends J{constructor(t,e){super(t,e)}}class $ extends X{constructor(t){if(super(t),this._comparator=(t,e)=>t-e,void 0!==t){const{comparator:e}=t;void 0!==e&&(this._comparator=e)}}createNode(t,e){return new Z(t,e)}add(t,e){let s=null,i=null;if(t instanceof Z?i=t:"number"==typeof t?i=this.createNode(t,e):null===t&&(i=null),null===this.root)this._setRoot(i),this._setSize(this.size+1),s=this.root;else{let t=this.root,e=!0;for(;e;)null!==t&&null!==i?this._compare(t.key,i.key)===Y.eq?(i&&(t.val=i.val),e=!1,s=t):this._compare(t.key,i.key)===Y.gt?void 0===t.left?(i&&(i.parent=t),t.left=i,this._setSize(this.size+1),e=!1,s=t.left):t.left&&(t=t.left):this._compare(t.key,i.key)===Y.lt&&(void 0===t.right?(i&&(i.parent=t),t.right=i,this._setSize(this.size+1),e=!1,s=t.right):t.right&&(t=t.right)):e=!1}return s}addMany(t,e,s=!0,i=this.iterationType){if(!s||-1!==t.indexOf(null))return super.addMany(t,e);const r=[],n=t.map(((t,s)=>[t,null==e?void 0:e[s]]));let h=[],o=[],l=[];if(function(t){for(const[e]of t)if(e instanceof Z)return!0;return!1}(n))h=n.sort(((t,e)=>t[0].key-e[0].key));else{if(!function(t){for(const[e]of t)if("number"==typeof e)return!0;return!1}(n))throw new Error("Invalid input keysOrNodes");h=n.sort(((t,e)=>t[0]-e[0]))}o=h.map((([t])=>t)),l=h.map((([,t])=>t));const a=(t,e)=>{if(0===t.length)return;const s=Math.floor((t.length-1)/2),i=this.add(t[s],null==e?void 0:e[s]);r.push(i),a(t.slice(0,s),null==e?void 0:e.slice(0,s)),a(t.slice(s+1),null==e?void 0:e.slice(s+1))};return i===K.RECURSIVE?a(o,l):(()=>{const t=[[0,h.length-1]];for(;t.length>0;){const e=t.pop();if(e){const[s,i]=e;if(s<=i){const e=s+Math.floor((i-s)/2),n=this.add(o[e],null==l?void 0:l[e]);r.push(n),t.push([e+1,i]),t.push([s,e-1])}}}})(),r}get(t,e=this._defaultCallbackByKey,s=this.root,i=this.iterationType){var r;return null!==(r=this.getNodes(t,e,!0,s,i)[0])&&void 0!==r?r:null}lastKey(t=this.root,e=this.iterationType){var s,i,r,n,h,o;return this._compare(0,1)===Y.lt?null!==(i=null===(s=this.getRightMost(t,e))||void 0===s?void 0:s.key)&&void 0!==i?i:0:this._compare(0,1)===Y.gt?null!==(n=null===(r=this.getLeftMost(t,e))||void 0===r?void 0:r.key)&&void 0!==n?n:0:null!==(o=null===(h=this.getRightMost(t,e))||void 0===h?void 0:h.key)&&void 0!==o?o:0}getNodes(t,e=this._defaultCallbackByKey,s=!1,i=this.root,r=this.iterationType){if(!i)return[];const n=[];if(r===K.RECURSIVE){const r=i=>{e(i)===t&&(n.push(i),s)||(i.left||i.right)&&(e===this._defaultCallbackByKey?(this._compare(i.key,t)===Y.gt&&i.left&&r(i.left),this._compare(i.key,t)===Y.lt&&i.right&&r(i.right)):(i.left&&r(i.left),i.right&&r(i.right)))};r(i)}else{const r=new v([i]);for(;r.size>0;){const i=r.shift();if(i){if(e(i)===t&&(n.push(i),s))return n;e===this._defaultCallbackByKey?(this._compare(i.key,t)===Y.gt&&i.left&&r.push(i.left),this._compare(i.key,t)===Y.lt&&i.right&&r.push(i.right)):(i.left&&r.push(i.left),i.right&&r.push(i.right))}}}return n}lesserOrGreaterTraverse(t=this._defaultCallbackByKey,e=Y.lt,s=this.root,i=this.iterationType){"number"==typeof s&&(s=this.get(s));const r=[];if(!s)return r;const n=s.key;if(!this.root)return r;if(i===K.RECURSIVE){const s=i=>{this._compare(i.key,n)===e&&r.push(t(i)),(i.left||i.right)&&(i.left&&this._compare(i.left.key,n)===e&&s(i.left),i.right&&this._compare(i.right.key,n)===e&&s(i.right))};return s(this.root),r}{const s=new v([this.root]);for(;s.size>0;){const i=s.shift();i&&(this._compare(i.key,n)===e&&r.push(t(i)),i.left&&this._compare(i.left.key,n)===e&&s.push(i.left),i.right&&this._compare(i.right.key,n)===e&&s.push(i.right))}return r}}perfectlyBalance(t=this.iterationType){const e=this.dfs((t=>t),"in"),s=e.length;if(this.clear(),e.length<1)return!1;if(t===K.RECURSIVE){const t=(s,i)=>{if(s>i)return;const r=s+Math.floor((i-s)/2),n=e[r];this.add(n.key,n.val),t(s,r-1),t(r+1,i)};return t(0,s-1),!0}{const t=[[0,s-1]];for(;t.length>0;){const s=t.pop();if(s){const[i,r]=s;if(i<=r){const s=i+Math.floor((r-i)/2),n=e[s];this.add(n.key,n.val),t.push([s+1,r]),t.push([i,s-1])}}}return!0}}isAVLBalanced(t=this.iterationType){var e,s;if(!this.root)return!0;let i=!0;if(t===K.RECURSIVE){const t=e=>{if(!e)return 0;const s=t(e.left),r=t(e.right);return Math.abs(s-r)>1&&(i=!1),Math.max(s,r)+1};t(this.root)}else{const t=[];let i=this.root,r=null;const n=new Map;for(;t.length>0||i;)if(i)t.push(i),i=i.left;else if(i=t[t.length-1],i.right&&r!==i.right)i=i.right;else if(i=t.pop(),i){const t=i.left&&null!==(e=n.get(i.left))&&void 0!==e?e:-1,h=i.right&&null!==(s=n.get(i.right))&&void 0!==s?s:-1;if(Math.abs(t-h)>1)return!1;n.set(i,1+Math.max(t,h)),r=i,i=null}}return i}_compare(t,e){const s=this._comparator(t,e);return s>0?Y.gt:s<0?Y.lt:Y.eq}}class tt{constructor({frequency:t=0,max:e}){this._freq=t,this._max=e,this._freqMap={0:0},this._msb=R(e),this._negativeCount=t<0?e:0}get freqMap(){return this._freqMap}set freqMap(t){this._freqMap=t}get msb(){return this._msb}set msb(t){this._msb=t}get negativeCount(){return this._negativeCount}set negativeCount(t){this._negativeCount=t}get freq(){return this._freq}get max(){return this._max}readSingle(t){return this._checkIndex(t),this._readSingle(t)}update(t,e){this._checkIndex(t);const s=this._readSingle(t);this._update(t,e),this._updateNegativeCount(s,s+e)}writeSingle(t,e){this._checkIndex(t),this._writeSingle(t,e)}read(t){if(!Number.isInteger(t))throw new Error("Invalid count");return this._read(Math.max(Math.min(t,this.max),0))}lowerBound(t){if(this.negativeCount>0)throw new Error("Sequence is not non-descending");return this._binarySearch(t,((t,e)=>t<e))}upperBound(t){if(this.negativeCount>0)throw new Error("Must not be descending");return this._binarySearch(t,((t,e)=>t<=e))}_getFrequency(t){return t in this.freqMap?this.freqMap[t]:this.freq*(t&-t)}_updateFrequency(t,e){this.freqMap[t]=this._getFrequency(t)+e}_checkIndex(t){if(!Number.isInteger(t))throw new Error("Invalid index: Index must be an integer.");if(t<0||t>=this.max)throw new Error("Index out of range: Index must be within the range [0, this.max).")}_readSingle(t){t+=1;let e=this._getFrequency(t);const s=t-(t&-t);for(t--;t!==s;)e-=this._getFrequency(t),t-=t&-t;return e}_updateNegativeCount(t,e){t<0&&e>=0?this.negativeCount--:t>=0&&e<0&&this.negativeCount++}_update(t,e){for(t+=1;t<=this.max;)this._updateFrequency(t,e),t+=t&-t}_writeSingle(t,e){const s=this._readSingle(t);this._update(t,e-s),this._updateNegativeCount(s,e)}_read(t){let e=t,s=0;for(;e;)s+=this._getFrequency(e),e-=e&-e;return s}_binarySearch(t,e){let s=0,i=this.msb<<1,r=t;for(;i>s+1;){const t=s+i>>1,n=this._getFrequency(t);t<=this.max&&e(n,r)?(r-=n,s=t):i=t}return s}}class et{constructor(t,e,s,i){this._start=0,this._end=0,this._val=null,this._sum=0,this._left=null,this._right=null,this._start=t,this._end=e,this._sum=s,this._val=i||null}get start(){return this._start}set start(t){this._start=t}get end(){return this._end}set end(t){this._end=t}get val(){return this._val}set val(t){this._val=t}get sum(){return this._sum}set sum(t){this._sum=t}get left(){return this._left}set left(t){this._left=t}get right(){return this._right}set right(t){this._right=t}}class st{constructor(t,e,s){this._values=[],this._start=0,e=e||0,s=s||t.length-1,this._values=t,this._start=e,this._end=s,t.length>0?this._root=this.build(e,s):(this._root=null,this._values=[])}get values(){return this._values}get start(){return this._start}get end(){return this._end}get root(){return this._root}build(t,e){if(t>e)return new et(t,e,0);if(t===e)return new et(t,e,this._values[t]);const s=t+Math.floor((e-t)/2),i=this.build(t,s),r=this.build(s+1,e),n=new et(t,e,i.sum+r.sum);return n.left=i,n.right=r,n}updateNode(t,e,s){const i=this.root||null;if(!i)return;const r=(t,e,s,i)=>{if(t.start===t.end&&t.start===e)return t.sum=s,void(void 0!==i&&(t.val=i));e<=t.start+Math.floor((t.end-t.start)/2)?t.left&&r(t.left,e,s,i):t.right&&r(t.right,e,s,i),t.left&&t.right&&(t.sum=t.left.sum+t.right.sum)};r(i,t,e,s)}querySumByRange(t,e){const s=this.root||null;if(!s)return 0;if(t<0||e>=this.values.length||t>e)return NaN;const i=(t,e,s)=>{if(e<=t.start&&s>=t.end)return t.sum;const r=t.start+Math.floor((t.end-t.start)/2);if(s<=r)return t.left?i(t.left,e,s):NaN;if(e>r)return t.right?i(t.right,e,s):NaN;{let n=0,h=0;return t.left&&(n=i(t.left,e,r)),t.right&&(h=i(t.right,r+1,s)),n+h}};return i(s,t,e)}_setValues(t){this._values=t}_setStart(t){this._start=t}_setEnd(t){this._end=t}_setRoot(t){this._root=t}}class it extends Z{constructor(t,e){super(t,e),this.height=0}}class rt extends ${constructor(t){super(t)}_swap(t,e){const{key:s,val:i,height:r}=e,n=this.createNode(s,i);return n&&(n.height=r,e.key=t.key,e.val=t.val,e.height=t.height,t.key=n.key,t.val=n.val,t.height=n.height),e}createNode(t,e){return new it(t,e)}add(t,e){const s=super.add(t,e);return s&&this._balancePath(s),s}delete(t){const e=super.delete(t);for(const{needBalanced:t}of e)t&&this._balancePath(t);return e}_balanceFactor(t){return t.right?t.left?t.right.height-t.left.height:+t.height:-t.height}_updateHeight(t){if(t.left||t.right)if(t.left)t.right?t.height=1+Math.max(t.right.height,t.left.height):t.height=1+t.left.height;else{const e=t.right?t.right.height:0;t.height=1+e}else t.height=0}_balancePath(t){const e=this.getPathToRoot(t,!1);for(let t=0;t<e.length;t++){const s=e[t];switch(this._updateHeight(s),this._balanceFactor(s)){case-2:s&&s.left&&(this._balanceFactor(s.left)<=0?this._balanceLL(s):this._balanceLR(s));break;case 2:s&&s.right&&(this._balanceFactor(s.right)>=0?this._balanceRR(s):this._balanceRL(s))}}}_balanceLL(t){const e=t.parent,s=t.left;t.parent=s,s&&s.right&&(s.right.parent=t),s&&(s.parent=e),t===this.root?s&&this._setRoot(s):(null==e?void 0:e.left)===t?e.left=s:e&&(e.right=s),s&&(t.left=s.right,s.right=t),this._updateHeight(t),s&&this._updateHeight(s)}_balanceLR(t){const e=t.parent,s=t.left;let i=null;s&&(i=s.right),t&&(t.parent=i),s&&(s.parent=i),i&&(i.left&&(i.left.parent=s),i.right&&(i.right.parent=t),i.parent=e),t===this.root?i&&this._setRoot(i):e&&(e.left===t?e.left=i:e.right=i),i&&(t.left=i.right,s&&(s.right=i.left),i.left=s,i.right=t),this._updateHeight(t),s&&this._updateHeight(s),i&&this._updateHeight(i)}_balanceRR(t){const e=t.parent,s=t.right;t.parent=s,s&&(s.left&&(s.left.parent=t),s.parent=e),t===this.root?s&&this._setRoot(s):e&&(e.left===t?e.left=s:e.right=s),s&&(t.right=s.left,s.left=t),this._updateHeight(t),s&&this._updateHeight(s)}_balanceRL(t){const e=t.parent,s=t.right;let i=null;s&&(i=s.left),t.parent=i,s&&(s.parent=i),i&&(i.left&&(i.left.parent=t),i.right&&(i.right.parent=s),i.parent=e),t===this.root?i&&this._setRoot(i):e&&(e.left===t?e.left=i:e.right=i),i&&(t.right=i.left),s&&i&&(s.left=i.right),i&&(i.left=t),i&&(i.right=s),this._updateHeight(t),s&&this._updateHeight(s),i&&this._updateHeight(i)}}class nt extends Z{constructor(t,e){super(t,e),this._color=W.RED}get color(){return this._color}set color(t){this._color=t}}class ht extends ${constructor(t){super(t)}createNode(t,e){return new nt(t,e)}}class ot extends it{constructor(t,e,s=1){super(t,e),this.count=s}}class lt extends rt{constructor(t){super(t),this._count=0}get count(){return this._count}createNode(t,e,s){return new ot(t,e,s)}_swap(t,e){const{key:s,val:i,count:r,height:n}=e,h=this.createNode(s,i,r);return h&&(h.height=n,e.key=t.key,e.val=t.val,e.count=t.count,e.height=t.height,t.key=h.key,t.val=h.val,t.count=h.count,t.height=h.height),e}add(t,e,s=1){let i,r;if(r=t instanceof ot?this.createNode(t.key,t.val,t.count):null===t?null:this.createNode(t,e,s),this.root){let t=this.root,e=!0;for(;e;)t?r&&(this._compare(t.key,r.key)===Y.eq?(t.val=r.val,t.count+=r.count,this._setCount(this.count+r.count),e=!1,i=t):this._compare(t.key,r.key)===Y.gt?void 0===t.left?(t.left=r,this._setSize(this.size+1),this._setCount(this.count+r.count),e=!1,i=t.left):t.left&&(t=t.left):this._compare(t.key,r.key)===Y.lt&&(void 0===t.right?(t.right=r,this._setSize(this.size+1),this._setCount(this.count+r.count),e=!1,i=t.right):t.right&&(t=t.right))):e=!1}else this._setRoot(r),this._setSize(this.size+1),r&&this._setCount(this.count+r.count),i=this.root;return i&&this._balancePath(i),i}_addTo(t,e){return e?void 0===e.left?(e.left=t,null!==t&&(this._setSize(this.size+1),this._setCount(this.count+t.count)),e.left):void 0===e.right?(e.right=t,null!==t&&(this._setSize(this.size+1),this._setCount(this.count+t.count)),e.right):void 0:void 0}addMany(t,e){const s=[];for(let i=0;i<t.length;i++){const r=t[i];r instanceof ot?s.push(this.add(r.key,r.val,r.count)):null!==r?s.push(this.add(r,null==e?void 0:e[i],1)):s.push(this.add(NaN,null,0))}return s}perfectlyBalance(t=this.iterationType){const e=this.dfs((t=>t),"in"),s=e.length;if(e.length<1)return!1;if(this.clear(),t===K.RECURSIVE){const t=(s,i)=>{if(s>i)return;const r=s+Math.floor((i-s)/2),n=e[r];this.add(n.key,n.val,n.count),t(s,r-1),t(r+1,i)};return t(0,s-1),!0}{const t=[[0,s-1]];for(;t.length>0;){const s=t.pop();if(s){const[i,r]=s;if(i<=r){const s=i+Math.floor((r-i)/2),n=e[s];this.add(n.key,n.val,n.count),t.push([s+1,r]),t.push([i,s-1])}}}return!0}}delete(t,e=!1){const s=[];if(!this.root)return s;const i=this.get(t);if(!i)return s;const r=(null==i?void 0:i.parent)?i.parent:null;let n=null,h=i;if(i.count>1&&!e)i.count--,this._setCount(this.count-1);else{if(i.left){const t=i.left?this.getRightMost(i.left):null;if(t){const e=t.parent;h=this._swap(i,t),e&&(e.right===t?e.right=t.left:e.left=t.left,n=e)}}else if(r){const{familyPosition:t}=i;t===G.LEFT||t===G.ROOT_LEFT?r.left=i.right:t!==G.RIGHT&&t!==G.ROOT_RIGHT||(r.right=i.right),n=r}else void 0!==i.right&&this._setRoot(i.right);this._setSize(this.size-1),this._setCount(this.count-h.count)}return s.push({deleted:h,needBalanced:n}),n&&this._balancePath(n),s}clear(){super.clear(),this._setCount(0)}_setCount(t){this._count=t}}class at{constructor(t,e,s){this._key=t,this._value=e||void 0,this._children=s||[]}get key(){return this._key}set key(t){this._key=t}get value(){return this._value}set value(t){this._value=t}get children(){return this._children}set children(t){this._children=t}addChildren(t){this.children||(this.children=[]),t instanceof at?this.children.push(t):this.children=this.children.concat(t)}getHeight(){let t=0;if(this){const e=(s,i)=>{i>t&&(t=i);const{children:r}=s;if(r)for(let t=0,s=r.length;t<s;t++)e(r[t],i+1)};e(this,0)}return t}}class ut extends z{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return e-t})){super(t)}}class ct extends z{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return t-e})){super(t)}}class dt extends A{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return t-e})){super(t)}}class ft extends A{constructor(t=((t,e)=>{if("number"!=typeof t||"number"!=typeof e)throw new Error("The a, b params of compare function must be number");return e-t})){super(t)}}class gt{constructor(t){const{row:e,col:s,initialVal:i}=t;this._matrix=new Array(e).fill(void 0).map((()=>new Array(s).fill(i||0)))}toArray(){return this._matrix}}class _t{constructor(t=0,e=0,s=1){this.x=t,this.y=e,this.w=s}get isZero(){return 0===this.x&&0===this.y}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}get lengthSq(){return this.x*this.x+this.y*this.y}get rounded(){return new _t(Math.round(this.x),Math.round(this.y))}static add(t,e){return new _t(t.x+e.x,t.y+e.y)}static subtract(t,e){return new _t(t.x-e.x,t.y-e.y)}static subtractValue(t,e){return new _t(t.x-e,t.y-e)}static multiply(t,e){return new _t(t.x*e,t.y*e)}static divide(t,e){return new _t(t.x/e,t.y/e)}static equals(t,e){return t.x===e.x&&t.y===e.y}static equalsRounded(t,e,s=12){const i=_t.abs(_t.subtract(t,e));return i.x<s&&i.y<s}static normalize(t){const e=t.length;return e>2220446049250313e-31?_t.divide(t,e):t}static truncate(t,e){return t.length>e?_t.multiply(_t.normalize(t),e):t}static perp(t){return new _t(-t.y,t.x)}static reverse(t){return new _t(-t.x,-t.y)}static abs(t){return new _t(Math.abs(t.x),Math.abs(t.y))}static dot(t,e){return t.x*e.x+t.y*e.y}static distance(t,e){const s=e.y-t.y,i=e.x-t.x;return Math.sqrt(s*s+i*i)}static distanceSq(t,e){const s=e.y-t.y,i=e.x-t.x;return s*s+i*i}static sign(t,e){return t.y*e.x>t.x*e.y?-1:1}static angle(t){const e=new _t(0,-1),s=Math.acos(_t.dot(t,e)/(t.length*e.length));return 1===_t.sign(t,e)?2*Math.PI-s:s}static random(t,e){const s=Math.floor(Math.random()*t-t/2),i=Math.floor(Math.random()*e-e/2);return new _t(s,i)}zero(){this.x=0,this.y=0}}const pt=_t;class vt{constructor(t){void 0===t?this._matrix=vt.identity:t instanceof pt?(this._matrix=vt.identity,this._matrix[0][0]=t.x,this._matrix[1][0]=t.y,this._matrix[2][0]=t.w):this._matrix=t}static get empty(){return[[],[],[]]}static get identity(){return[[1,0,0],[0,1,0],[0,0,1]]}get m(){return this._matrix}toVector(){return new pt(this._matrix[0][0],this._matrix[1][0])}static add(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]+e.m[i][r];return new vt(s)}static subtract(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]-e.m[i][r];return new vt(s)}static multiply(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++){s[i][r]=0;for(let n=0;n<3;n++)s[i][r]+=t.m[i][n]*e.m[n][r]}return new vt(s)}static multiplyByValue(t,e){const s=vt.empty;for(let i=0;i<3;i++)for(let r=0;r<3;r++)s[i][r]=t.m[i][r]*e;return new vt(s)}static multiplyByVector(t,e){return vt.multiply(t,new vt(e)).toVector()}static view(t,e){const s=t/2,i=e/2,r=Math.cos(Math.PI);return new vt([[1,0,s],[0,1*r,i],[0,0,1]])}static scale(t){return vt.multiplyByValue(new vt,t)}static rotate(t){const e=Math.cos(t),s=Math.sin(t);return new vt([[e,-s,0],[s,e,0],[0,0,1]])}static translate(t){return new vt([[1,0,t.x],[0,1,t.y],[0,0,t.w]])}}class yt{constructor(t,e){this.direction=t,this.turn=()=>new yt(e[t],e)}}class mt{constructor({matrix:t,turning:e,onMove:s,init:{cur:i,charDir:r,VISITED:n}}){this._matrix=t,this._cur=i,this._character=new yt(r,e),this.onMove=s,this.onMove&&this.onMove(this._cur),this._VISITED=n,this._matrix[this._cur[0]][this._cur[1]]=this._VISITED}start(){for(;this.check(this._character.direction)||this.check(this._character.turn().direction);){const{direction:t}=this._character;this.check(t)?this.move(t):this.check(this._character.turn().direction)&&(this._character=this._character.turn())}}check(t){let e,s;const i=this._matrix,[r,n]=this._cur;switch(t){case"up":if(s=i[r-1],!s)return!1;e=s[n];break;case"right":e=i[r][n+1];break;case"down":if(s=i[r+1],!s)return!1;e=s[n];break;case"left":e=i[r][n-1]}return void 0!==e&&e!==this._VISITED}move(t){switch(t){case"up":this._cur[0]--;break;case"right":this._cur[1]++;break;case"down":this._cur[0]++;break;case"left":this._cur[1]--}const[e,s]=this._cur;this._matrix[e][s]=this._VISITED,this.onMove&&this.onMove(this._cur)}}class xt{constructor(t){this._key=t,this._isEnd=!1,this._children=new Map}get key(){return this._key}set key(t){this._key=t}get children(){return this._children}set children(t){this._children=t}get isEnd(){return this._isEnd}set isEnd(t){this._isEnd=t}}class bt{constructor(t,e=!0){if(this._root=new xt(""),this._caseSensitive=e,t)for(const e of t)this.add(e)}get root(){return this._root}set root(t){this._root=t}add(t){t=this._caseProcess(t);let e=this.root;for(const s of t){let t=e.children.get(s);t||(t=new xt(s),e.children.set(s,t)),e=t}return e.isEnd=!0,!0}has(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return e.isEnd}_caseProcess(t){return this._caseSensitive||(t=t.toLowerCase()),t}delete(t){t=this._caseProcess(t);let e=!1;const s=(i,r)=>{const n=t[r],h=i.children.get(n);return!!h&&(r===t.length-1?!!h.isEnd&&(h.children.size>0?h.isEnd=!1:i.children.delete(n),e=!0,!0):!(!s(h,r+1)||i.isEnd||0!==h.children.size||(i.children.delete(n),0)))};return s(this.root,0),e}getHeight(){const t=this.root;let e=0;if(t){const s=(t,i)=>{i>e&&(e=i);const{children:r}=t;if(r)for(const t of r.entries())s(t[1],i+1)};s(t,0)}return e}hasPurePrefix(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return!e.isEnd}hasPrefix(t){t=this._caseProcess(t);let e=this.root;for(const s of t){const t=e.children.get(s);if(!t)return!1;e=t}return!0}hasCommonPrefix(t){t=this._caseProcess(t);let e="";const s=i=>{e+=i.key,e!==t&&(i.isEnd||i&&i.children&&1===i.children.size&&s(Array.from(i.children.values())[0]))};return s(this.root),e===t}getLongestCommonPrefix(){let t="";const e=s=>{t+=s.key,s.isEnd||s&&s.children&&1===s.children.size&&e(Array.from(s.children.values())[0])};return e(this.root),t}getWords(t="",e=Number.MAX_SAFE_INTEGER){t=this._caseProcess(t);const s=[];let i=0,r=this.root;if(t)for(const e of t){const t=r.children.get(e);t&&(r=t)}return r!==this.root&&function t(r,n){for(const e of r.children.keys()){const s=r.children.get(e);void 0!==s&&t(s,n.concat(e))}if(r.isEnd){if(i>e-1)return;s.push(n),i++}}(r,t),s}}return e})()));
3
3
  //# sourceMappingURL=bundle.min.js.map