@make-software/ces-js-parser
Version:
Parser for contract-level events encoded with Casper Event Standard (CES)
1 lines • 994 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={105:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchContractSchemasBytes=t.parseSchemaFromBytesWithRemainder=t.parseSchemasFromBytes=void 0;var i=r(276),a=r(337);t.parseSchemasFromBytes=function(e){for(var t=new i.CLTypeMap(i.CLTypeString,new i.CLTypeList(new i.CLTypeTuple2(i.CLTypeString,new i.CLTypeDynamic(i.TypeID.String,i.CLTypeString)))),r={},n=i.CLValueParser.fromBytesByType(e,t).result.map.getMap(),o=0,a=Object.entries(n);o<a.length;o++){var s=a[o],u=s[0],c=s[1];r[u]=c.list.elements.map((function(e){return{property:e.tuple2.inner1.stringVal.toString(),value:e.tuple2.inner2.type.inner}}))}return r},t.parseSchemaFromBytesWithRemainder=function(e){var t=new i.CLTypeList(new i.CLTypeTuple2(i.CLTypeString,new i.CLTypeDynamic(i.TypeID.String,i.CLTypeString))),r=i.CLValueParser.fromBytesByType(e,t);return{result:r.result.list.elements.map((function(e){return{property:e.tuple2.inner1.stringVal.toString(),value:e.tuple2.inner2.type.inner}})),bytes:r.bytes}},t.fetchContractSchemasBytes=function(e,t,r){return n(this,void 0,void 0,(function(){var n,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,e.getStateItem(r,"hash-".concat(t),[])];case 1:if(!(n=o.sent())||!n.storedValue.contract)throw new Error("contract data not found");if(!(i=n.storedValue.contract.namedKeys.keys.find((function(e){return e.name===a.EVENTS_SCHEMA_NAMED_KEY}))))throw new Error("'".concat(a.EVENTS_SCHEMA_NAMED_KEY,"' uref not found for contract '").concat(t,"'"));return[4,e.getStateItem(r,i.key.toString(),[])];case 2:if(!(s=o.sent()).storedValue.clValue)throw new Error("no CLValue for schema");return[2,s.storedValue.clValue.bytes()]}}))}))}},164:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEventDataFromBytes=t.parseEventNameAndData=t.parseEventNameWithRemainder=void 0;var n=r(276);function o(e){var t=n.CLValueParser.fromBytesByType(e,n.CLTypeString),r=t.result.toString();if(!r.startsWith("event_"))throw new Error("no event_ prefix for event");return{result:r.replace("event_",""),bytes:t.bytes}}function i(e,t){for(var r={},o=t,i=0,a=e;i<a.length;i++){var s=a[i],u=n.CLValueParser.fromBytesByType(o,s.value);if(!u.bytes)throw new Error("remainder is empty");r[s.property]=u.result,o=u.bytes}return r}t.parseEventNameWithRemainder=o,t.parseEventNameAndData=function(e,t){var r=n.Conversions.decodeBase16(e),a=n.CLValueParser.fromBytesWithType(r);if(a.result.bytes().length<4)throw new Error("invalid event bytes");var s=o(a.result.bytes().subarray(4)),u=t[s.result];if(!u)throw new Error("event name not in schema");return{name:s.result,data:i(u,s.bytes)}},t.parseEventDataFromBytes=i},276:e=>{var t;self,t=()=>(()=>{var e={6667:(e,t,r)=>{"use strict";r.d(t,{r:()=>n});const n="bignumber/5.7.0"},7457:(e,t,r)=>{"use strict";r.d(t,{Os:()=>v,YR:()=>d,gH:()=>p,ii:()=>w});var n=r(2046),o=r.n(n),i=r(8905),a=r(7720),s=r(6667),u=o().BN;const c=new a.Vy(s.r),f={},l=9007199254740991;function d(e){return null!=e&&(p.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||(0,i.isHexString)(e)||"bigint"==typeof e||(0,i.isBytes)(e))}let h=!1;class p{constructor(e,t){e!==f&&c.throwError("cannot call constructor directly; use BigNumber.from",a.Vy.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return m(b(this).fromTwos(e))}toTwos(e){return m(b(this).toTwos(e))}abs(){return"-"===this._hex[0]?p.from(this._hex.substring(1)):this}add(e){return m(b(this).add(b(e)))}sub(e){return m(b(this).sub(b(e)))}div(e){return p.from(e).isZero()&&g("division-by-zero","div"),m(b(this).div(b(e)))}mul(e){return m(b(this).mul(b(e)))}mod(e){const t=b(e);return t.isNeg()&&g("division-by-zero","mod"),m(b(this).umod(t))}pow(e){const t=b(e);return t.isNeg()&&g("negative-power","pow"),m(b(this).pow(t))}and(e){const t=b(e);return(this.isNegative()||t.isNeg())&&g("unbound-bitwise-result","and"),m(b(this).and(t))}or(e){const t=b(e);return(this.isNegative()||t.isNeg())&&g("unbound-bitwise-result","or"),m(b(this).or(t))}xor(e){const t=b(e);return(this.isNegative()||t.isNeg())&&g("unbound-bitwise-result","xor"),m(b(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&g("negative-width","mask"),m(b(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&g("negative-width","shl"),m(b(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&g("negative-width","shr"),m(b(this).shrn(e))}eq(e){return b(this).eq(b(e))}lt(e){return b(this).lt(b(e))}lte(e){return b(this).lte(b(e))}gt(e){return b(this).gt(b(e))}gte(e){return b(this).gte(b(e))}isNegative(){return"-"===this._hex[0]}isZero(){return b(this).isZero()}toNumber(){try{return b(this).toNumber()}catch(e){g("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return c.throwError("this platform does not support BigInt",a.Vy.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?h||(h=!0,c.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?c.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",a.Vy.errors.UNEXPECTED_ARGUMENT,{}):c.throwError("BigNumber.toString does not accept parameters",a.Vy.errors.UNEXPECTED_ARGUMENT,{})),b(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof p)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new p(f,y(e)):e.match(/^-?[0-9]+$/)?new p(f,y(new u(e))):c.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&g("underflow","BigNumber.from",e),(e>=l||e<=-l)&&g("overflow","BigNumber.from",e),p.from(String(e));const t=e;if("bigint"==typeof t)return p.from(t.toString());if((0,i.isBytes)(t))return p.from((0,i.hexlify)(t));if(t)if(t.toHexString){const e=t.toHexString();if("string"==typeof e)return p.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&((0,i.isHexString)(e)||"-"===e[0]&&(0,i.isHexString)(e.substring(1))))return p.from(e)}return c.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function y(e){if("string"!=typeof e)return y(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&c.throwArgumentError("invalid hex","value",e),"0x00"===(e=y(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function m(e){return p.from(y(e))}function b(e){const t=p.from(e).toHexString();return"-"===t[0]?new u("-"+t.substring(3),16):new u(t.substring(2),16)}function g(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),c.throwError(e,a.Vy.errors.NUMERIC_FAULT,n)}function v(e){return new u(e,36).toString(16)}function w(e){return new u(e,16).toString(36)}},6077:(e,t,r)=>{"use strict";r.r(t),r.d(t,{BigNumber:()=>n.gH,FixedFormat:()=>m,FixedNumber:()=>b,_base16To36:()=>n.ii,_base36To16:()=>n.Os,formatFixed:()=>p,parseFixed:()=>y});var n=r(7457),o=r(8905),i=r(7720),a=r(6667);const s=new i.Vy(a.r),u={},c=n.gH.from(0),f=n.gH.from(-1);function l(e,t,r,n){const o={fault:t,operation:r};return void 0!==n&&(o.value=n),s.throwError(e,i.Vy.errors.NUMERIC_FAULT,o)}let d="0";for(;d.length<256;)d+=d;function h(e){if("number"!=typeof e)try{e=n.gH.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+d.substring(0,e):s.throwArgumentError("invalid decimal size","decimals",e)}function p(e,t){null==t&&(t=0);const r=h(t),o=(e=n.gH.from(e)).lt(c);o&&(e=e.mul(f));let i=e.mod(r).toString();for(;i.length<r.length-1;)i="0"+i;i=i.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=e.div(r).toString();return e=1===r.length?a:a+"."+i,o&&(e="-"+e),e}function y(e,t){null==t&&(t=0);const r=h(t);"string"==typeof e&&e.match(/^-?[0-9.]+$/)||s.throwArgumentError("invalid decimal value","value",e);const o="-"===e.substring(0,1);o&&(e=e.substring(1)),"."===e&&s.throwArgumentError("missing value","value",e);const i=e.split(".");i.length>2&&s.throwArgumentError("too many decimal points","value",e);let a=i[0],u=i[1];for(a||(a="0"),u||(u="0");"0"===u[u.length-1];)u=u.substring(0,u.length-1);for(u.length>r.length-1&&l("fractional component exceeds decimals","underflow","parseFixed"),""===u&&(u="0");u.length<r.length-1;)u+="0";const c=n.gH.from(a),d=n.gH.from(u);let p=c.mul(r).add(d);return o&&(p=p.mul(f)),p}class m{constructor(e,t,r,n){e!==u&&s.throwError("cannot use FixedFormat constructor; use FixedFormat.from",i.Vy.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=r,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(r)+"x"+String(n),this._multiplier=h(n),Object.freeze(this)}static from(e){if(e instanceof m)return e;"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,r=128,n=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const o=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);o||s.throwArgumentError("invalid fixed format","format",e),t="u"!==o[1],r=parseInt(o[2]),n=parseInt(o[3])}else if(e){const o=(t,r,n)=>null==e[t]?n:(typeof e[t]!==r&&s.throwArgumentError("invalid fixed format ("+t+" not "+r+")","format."+t,e[t]),e[t]);t=o("signed","boolean",t),r=o("width","number",r),n=o("decimals","number",n)}return r%8&&s.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&s.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new m(u,t,r,n)}}class b{constructor(e,t,r,n){e!==u&&s.throwError("cannot use FixedNumber constructor; use FixedNumber.from",i.Vy.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&s.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=y(this._value,this.format.decimals),r=y(e._value,e.format.decimals);return b.fromValue(t.add(r),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=y(this._value,this.format.decimals),r=y(e._value,e.format.decimals);return b.fromValue(t.sub(r),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=y(this._value,this.format.decimals),r=y(e._value,e.format.decimals);return b.fromValue(t.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=y(this._value,this.format.decimals),r=y(e._value,e.format.decimals);return b.fromValue(t.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=b.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return this.isNegative()&&r&&(t=t.subUnsafe(g.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");1===e.length&&e.push("0");let t=b.from(e[0],this.format);const r=!e[1].match(/^(0*)$/);return!this.isNegative()&&r&&(t=t.addUnsafe(g.toFormat(t.format))),t}round(e){null==e&&(e=0);const t=this.toString().split(".");if(1===t.length&&t.push("0"),(e<0||e>80||e%1)&&s.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const r=b.from("1"+d.substring(0,e),this.format),n=v.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(n).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(e){if(null==e)return this._hex;e%8&&s.throwArgumentError("invalid byte width","width",e);const t=n.gH.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return(0,o.hexZeroPad)(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return b.fromString(this._value,e)}static fromValue(e,t,r){return null!=r||null==t||(0,n.YR)(t)||(r=t,t=null),null==t&&(t=0),null==r&&(r="fixed"),b.fromString(p(e,t),m.from(r))}static fromString(e,t){null==t&&(t="fixed");const r=m.from(t),n=y(e,r.decimals);!r.signed&&n.lt(c)&&l("unsigned value cannot be negative","overflow","value",e);let i=null;r.signed?i=n.toTwos(r.width).toHexString():(i=n.toHexString(),i=(0,o.hexZeroPad)(i,r.width/8));const a=p(n,r.decimals);return new b(u,i,a,r)}static fromBytes(e,t){null==t&&(t="fixed");const r=m.from(t);if((0,o.arrayify)(e).length>r.width/8)throw new Error("overflow");let i=n.gH.from(e);r.signed&&(i=i.fromTwos(r.width));const a=i.toTwos((r.signed?0:1)+r.width).toHexString(),s=p(i,r.decimals);return new b(u,a,s,r)}static from(e,t){if("string"==typeof e)return b.fromString(e,t);if((0,o.isBytes)(e))return b.fromBytes(e,t);try{return b.fromValue(e,0,t)}catch(e){if(e.code!==i.Vy.errors.INVALID_ARGUMENT)throw e}return s.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!(!e||!e._isFixedNumber)}}const g=b.from(1),v=b.from("0.5")},2046:function(e,t,r){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(1848).Buffer}catch(e){}function s(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+e)}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,r,o){for(var i=0,a=0,s=Math.min(e.length,r),u=t;u<s;u++){var c=e.charCodeAt(u)-48;i*=o,a=c>=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&a<o,"Invalid character"),i+=a}return i}function f(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,r):(this._parseBase(e,t,o),"le"===r&&this._initArray(this.toArray(),t,r)))},i.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},i.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,a,s=0;if("be"===r)for(o=e.length-1,i=0;o>=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===r)for(o=0,i=0;o<e.length;o+=3)a=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this._strip()},i.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,i=0,a=0;if("be"===r)for(n=e.length-1;n>=t;n-=2)o=u(e,t,n)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(n=(e.length-t)%2==0?t+1:t;n<e.length;n+=2)o=u(e,t,n)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this._strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,o=1;o<=67108863;o*=t)n++;n--,o=o/t|0;for(var i=e.length-r,a=i%n,s=Math.min(i,i-a)+r,u=0,f=r;f<s;f+=n)u=c(e,f,f+n,t),this.imuln(o),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var l=1;for(u=c(e,f,e.length,t),f=0;f<a;f++)l*=t;this.imuln(l),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},i.prototype._move=function(e){f(e,this)},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(e){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function y(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c<n;c++){for(var f=u>>>26,l=67108863&u,d=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=d;h++){var p=c-h|0;f+=(a=(o=0|e.words[p])*(i=0|t.words[h])+l)/67108864|0,l=67108863&a}r.words[c]=0|l,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var o=0,i=0,a=0;a<this.length;a++){var s=this.words[a],u=(16777215&(s<<o|i)).toString(16);i=s>>>24-o&16777215,(o+=2)>=26&&(o-=26,a--),r=0!==i||a!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==i&&(r=i.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=h[e],f=p[e];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var y=l.modrn(f).toString(e);r=(l=l.idivn(f)).isZero()?y+r:d[c-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16,2)},a&&(i.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,r){this._strip();var o=this.byteLength(),i=r||Math.max(1,o);n(o<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,i);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,o),a},i.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,o=0,i=0;o<this.length;o++){var a=this.words[o]<<i|n;e[r++]=255&a,r<e.length&&(e[r++]=a>>8&255),r<e.length&&(e[r++]=a>>16&255),6===i?(r<e.length&&(e[r++]=a>>24&255),n=0,i=0):(n=a>>>24,i+=2)}if(r<e.length)for(e[r++]=n;r<e.length;)e[r++]=0},i.prototype._toArrayLikeBE=function(e,t){for(var r=e.length-1,n=0,o=0,i=0;o<this.length;o++){var a=this.words[o]<<i|n;e[r--]=255&a,r>=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===i?(r>=0&&(e[r--]=a>>24&255),n=0,i=0):(n=a>>>24,i+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},i.prototype.ior=function(e){return n(!(this.negative|e.negative)),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this._strip()},i.prototype.iand=function(e){return n(!(this.negative|e.negative)),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this._strip()},i.prototype.ixor=function(e){return n(!(this.negative|e.negative)),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return r>0&&(this.words[o]=~this.words[o]&67108863>>26-r),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,o=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<o:this.words[r]&~(1<<o),this._strip()},i.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var o=0,i=0;i<n.length;i++)t=(0|r.words[i])+(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<r.length;i++)t=(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=r.length,0!==o)this.words[this.length]=o,this.length++;else if(r!==this)for(;i<r.length;i++)this.words[i]=r.words[i];return this},i.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(r=this,n=e):(r=e,n=this);for(var i=0,a=0;a<n.length;a++)i=(t=(0|r.words[a])-(0|n.words[a])+i)>>26,this.words[a]=67108863&t;for(;0!==i&&a<r.length;a++)i=(t=(0|r.words[a])+i)>>26,this.words[a]=67108863&t;if(0===i&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(e){return this.clone().isub(e)};var m=function(e,t,r){var n,o,i,a=e.words,s=t.words,u=r.words,c=0,f=0|a[0],l=8191&f,d=f>>>13,h=0|a[1],p=8191&h,y=h>>>13,m=0|a[2],b=8191&m,g=m>>>13,v=0|a[3],w=8191&v,S=v>>>13,_=0|a[4],M=8191&_,A=_>>>13,E=0|a[5],O=8191&E,j=E>>>13,T=0|a[6],N=8191&T,P=T>>>13,B=0|a[7],R=8191&B,C=B>>>13,x=0|a[8],I=8191&x,k=x>>>13,H=0|a[9],L=8191&H,U=H>>>13,D=0|s[0],V=8191&D,z=D>>>13,J=0|s[1],K=8191&J,F=J>>>13,q=0|s[2],W=8191&q,G=q>>>13,$=0|s[3],Z=8191&$,Y=$>>>13,X=0|s[4],Q=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,fe=0|s[8],le=8191&fe,de=fe>>>13,he=0|s[9],pe=8191&he,ye=he>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(n=Math.imul(l,V))|0)+((8191&(o=(o=Math.imul(l,z))+Math.imul(d,V)|0))<<13)|0;c=((i=Math.imul(d,z))+(o>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,V),o=(o=Math.imul(p,z))+Math.imul(y,V)|0,i=Math.imul(y,z);var be=(c+(n=n+Math.imul(l,K)|0)|0)+((8191&(o=(o=o+Math.imul(l,F)|0)+Math.imul(d,K)|0))<<13)|0;c=((i=i+Math.imul(d,F)|0)+(o>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(b,V),o=(o=Math.imul(b,z))+Math.imul(g,V)|0,i=Math.imul(g,z),n=n+Math.imul(p,K)|0,o=(o=o+Math.imul(p,F)|0)+Math.imul(y,K)|0,i=i+Math.imul(y,F)|0;var ge=(c+(n=n+Math.imul(l,W)|0)|0)+((8191&(o=(o=o+Math.imul(l,G)|0)+Math.imul(d,W)|0))<<13)|0;c=((i=i+Math.imul(d,G)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(w,V),o=(o=Math.imul(w,z))+Math.imul(S,V)|0,i=Math.imul(S,z),n=n+Math.imul(b,K)|0,o=(o=o+Math.imul(b,F)|0)+Math.imul(g,K)|0,i=i+Math.imul(g,F)|0,n=n+Math.imul(p,W)|0,o=(o=o+Math.imul(p,G)|0)+Math.imul(y,W)|0,i=i+Math.imul(y,G)|0;var ve=(c+(n=n+Math.imul(l,Z)|0)|0)+((8191&(o=(o=o+Math.imul(l,Y)|0)+Math.imul(d,Z)|0))<<13)|0;c=((i=i+Math.imul(d,Y)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(M,V),o=(o=Math.imul(M,z))+Math.imul(A,V)|0,i=Math.imul(A,z),n=n+Math.imul(w,K)|0,o=(o=o+Math.imul(w,F)|0)+Math.imul(S,K)|0,i=i+Math.imul(S,F)|0,n=n+Math.imul(b,W)|0,o=(o=o+Math.imul(b,G)|0)+Math.imul(g,W)|0,i=i+Math.imul(g,G)|0,n=n+Math.imul(p,Z)|0,o=(o=o+Math.imul(p,Y)|0)+Math.imul(y,Z)|0,i=i+Math.imul(y,Y)|0;var we=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(o=(o=o+Math.imul(l,ee)|0)+Math.imul(d,Q)|0))<<13)|0;c=((i=i+Math.imul(d,ee)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,V),o=(o=Math.imul(O,z))+Math.imul(j,V)|0,i=Math.imul(j,z),n=n+Math.imul(M,K)|0,o=(o=o+Math.imul(M,F)|0)+Math.imul(A,K)|0,i=i+Math.imul(A,F)|0,n=n+Math.imul(w,W)|0,o=(o=o+Math.imul(w,G)|0)+Math.imul(S,W)|0,i=i+Math.imul(S,G)|0,n=n+Math.imul(b,Z)|0,o=(o=o+Math.imul(b,Y)|0)+Math.imul(g,Z)|0,i=i+Math.imul(g,Y)|0,n=n+Math.imul(p,Q)|0,o=(o=o+Math.imul(p,ee)|0)+Math.imul(y,Q)|0,i=i+Math.imul(y,ee)|0;var Se=(c+(n=n+Math.imul(l,re)|0)|0)+((8191&(o=(o=o+Math.imul(l,ne)|0)+Math.imul(d,re)|0))<<13)|0;c=((i=i+Math.imul(d,ne)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(N,V),o=(o=Math.imul(N,z))+Math.imul(P,V)|0,i=Math.imul(P,z),n=n+Math.imul(O,K)|0,o=(o=o+Math.imul(O,F)|0)+Math.imul(j,K)|0,i=i+Math.imul(j,F)|0,n=n+Math.imul(M,W)|0,o=(o=o+Math.imul(M,G)|0)+Math.imul(A,W)|0,i=i+Math.imul(A,G)|0,n=n+Math.imul(w,Z)|0,o=(o=o+Math.imul(w,Y)|0)+Math.imul(S,Z)|0,i=i+Math.imul(S,Y)|0,n=n+Math.imul(b,Q)|0,o=(o=o+Math.imul(b,ee)|0)+Math.imul(g,Q)|0,i=i+Math.imul(g,ee)|0,n=n+Math.imul(p,re)|0,o=(o=o+Math.imul(p,ne)|0)+Math.imul(y,re)|0,i=i+Math.imul(y,ne)|0;var _e=(c+(n=n+Math.imul(l,ie)|0)|0)+((8191&(o=(o=o+Math.imul(l,ae)|0)+Math.imul(d,ie)|0))<<13)|0;c=((i=i+Math.imul(d,ae)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(R,V),o=(o=Math.imul(R,z))+Math.imul(C,V)|0,i=Math.imul(C,z),n=n+Math.imul(N,K)|0,o=(o=o+Math.imul(N,F)|0)+Math.imul(P,K)|0,i=i+Math.imul(P,F)|0,n=n+Math.imul(O,W)|0,o=(o=o+Math.imul(O,G)|0)+Math.imul(j,W)|0,i=i+Math.imul(j,G)|0,n=n+Math.imul(M,Z)|0,o=(o=o+Math.imul(M,Y)|0)+Math.imul(A,Z)|0,i=i+Math.imul(A,Y)|0,n=n+Math.imul(w,Q)|0,o=(o=o+Math.imul(w,ee)|0)+Math.imul(S,Q)|0,i=i+Math.imul(S,ee)|0,n=n+Math.imul(b,re)|0,o=(o=o+Math.imul(b,ne)|0)+Math.imul(g,re)|0,i=i+Math.imul(g,ne)|0,n=n+Math.imul(p,ie)|0,o=(o=o+Math.imul(p,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0;var Me=(c+(n=n+Math.imul(l,ue)|0)|0)+((8191&(o=(o=o+Math.imul(l,ce)|0)+Math.imul(d,ue)|0))<<13)|0;c=((i=i+Math.imul(d,ce)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(I,V),o=(o=Math.imul(I,z))+Math.imul(k,V)|0,i=Math.imul(k,z),n=n+Math.imul(R,K)|0,o=(o=o+Math.imul(R,F)|0)+Math.imul(C,K)|0,i=i+Math.imul(C,F)|0,n=n+Math.imul(N,W)|0,o=(o=o+Math.imul(N,G)|0)+Math.imul(P,W)|0,i=i+Math.imul(P,G)|0,n=n+Math.imul(O,Z)|0,o=(o=o+Math.imul(O,Y)|0)+Math.imul(j,Z)|0,i=i+Math.imul(j,Y)|0,n=n+Math.imul(M,Q)|0,o=(o=o+Math.imul(M,ee)|0)+Math.imul(A,Q)|0,i=i+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,o=(o=o+Math.imul(w,ne)|0)+Math.imul(S,re)|0,i=i+Math.imul(S,ne)|0,n=n+Math.imul(b,ie)|0,o=(o=o+Math.imul(b,ae)|0)+Math.imul(g,ie)|0,i=i+Math.imul(g,ae)|0,n=n+Math.imul(p,ue)|0,o=(o=o+Math.imul(p,ce)|0)+Math.imul(y,ue)|0,i=i+Math.imul(y,ce)|0;var Ae=(c+(n=n+Math.imul(l,le)|0)|0)+((8191&(o=(o=o+Math.imul(l,de)|0)+Math.imul(d,le)|0))<<13)|0;c=((i=i+Math.imul(d,de)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(L,V),o=(o=Math.imul(L,z))+Math.imul(U,V)|0,i=Math.imul(U,z),n=n+Math.imul(I,K)|0,o=(o=o+Math.imul(I,F)|0)+Math.imul(k,K)|0,i=i+Math.imul(k,F)|0,n=n+Math.imul(R,W)|0,o=(o=o+Math.imul(R,G)|0)+Math.imul(C,W)|0,i=i+Math.imul(C,G)|0,n=n+Math.imul(N,Z)|0,o=(o=o+Math.imul(N,Y)|0)+Math.imul(P,Z)|0,i=i+Math.imul(P,Y)|0,n=n+Math.imul(O,Q)|0,o=(o=o+Math.imul(O,ee)|0)+Math.imul(j,Q)|0,i=i+Math.imul(j,ee)|0,n=n+Math.imul(M,re)|0,o=(o=o+Math.imul(M,ne)|0)+Math.imul(A,re)|0,i=i+Math.imul(A,ne)|0,n=n+Math.imul(w,ie)|0,o=(o=o+Math.imul(w,ae)|0)+Math.imul(S,ie)|0,i=i+Math.imul(S,ae)|0,n=n+Math.imul(b,ue)|0,o=(o=o+Math.imul(b,ce)|0)+Math.imul(g,ue)|0,i=i+Math.imul(g,ce)|0,n=n+Math.imul(p,le)|0,o=(o=o+Math.imul(p,de)|0)+Math.imul(y,le)|0,i=i+Math.imul(y,de)|0;var Ee=(c+(n=n+Math.imul(l,pe)|0)|0)+((8191&(o=(o=o+Math.imul(l,ye)|0)+Math.imul(d,pe)|0))<<13)|0;c=((i=i+Math.imul(d,ye)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(L,K),o=(o=Math.imul(L,F))+Math.imul(U,K)|0,i=Math.imul(U,F),n=n+Math.imul(I,W)|0,o=(o=o+Math.imul(I,G)|0)+Math.imul(k,W)|0,i=i+Math.imul(k,G)|0,n=n+Math.imul(R,Z)|0,o=(o=o+Math.imul(R,Y)|0)+Math.imul(C,Z)|0,i=i+Math.imul(C,Y)|0,n=n+Math.imul(N,Q)|0,o=(o=o+Math.imul(N,ee)|0)+Math.imul(P,Q)|0,i=i+Math.imul(P,ee)|0,n=n+Math.imul(O,re)|0,o=(o=o+Math.imul(O,ne)|0)+Math.imul(j,re)|0,i=i+Math.imul(j,ne)|0,n=n+Math.imul(M,ie)|0,o=(o=o+Math.imul(M,ae)|0)+Math.imul(A,ie)|0,i=i+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,o=(o=o+Math.imul(w,ce)|0)+Math.imul(S,ue)|0,i=i+Math.imul(S,ce)|0,n=n+Math.imul(b,le)|0,o=(o=o+Math.imul(b,de)|0)+Math.imul(g,le)|0,i=i+Math.imul(g,de)|0;var Oe=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(o=(o=o+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;c=((i=i+Math.imul(y,ye)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(L,W),o=(o=Math.imul(L,G))+Math.imul(U,W)|0,i=Math.imul(U,G),n=n+Math.imul(I,Z)|0,o=(o=o+Math.imul(I,Y)|0)+Math.imul(k,Z)|0,i=i+Math.imul(k,Y)|0,n=n+Math.imul(R,Q)|0,o=(o=o+Math.imul(R,ee)|0)+Math.imul(C,Q)|0,i=i+Math.imul(C,ee)|0,n=n+Math.imul(N,re)|0,o=(o=o+Math.imul(N,ne)|0)+Math.imul(P,re)|0,i=i+Math.imul(P,ne)|0,n=n+Math.imul(O,ie)|0,o=(o=o+Math.imul(O,ae)|0)+Math.imul(j,ie)|0,i=i+Math.imul(j,ae)|0,n=n+Math.imul(M,ue)|0,o=(o=o+Math.imul(M,ce)|0)+Math.imul(A,ue)|0,i=i+Math.imul(A,ce)|0,n=n+Math.imul(w,le)|0,o=(o=o+Math.imul(w,de)|0)+Math.imul(S,le)|0,i=i+Math.imul(S,de)|0;var je=(c+(n=n+Math.imul(b,pe)|0)|0)+((8191&(o=(o=o+Math.imul(b,ye)|0)+Math.imul(g,pe)|0))<<13)|0;c=((i=i+Math.imul(g,ye)|0)+(o>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(L,Z),o=(o=Math.imul(L,Y))+Math.imul(U,Z)|0,i=Math.imul(U,Y),n=n+Math.imul(I,Q)|0,o=(o=o+Math.imul(I,ee)|0)+Math.imul(k,Q)|0,i=i+Math.imul(k,ee)|0,n=n+Math.imul(R,re)|0,o=(o=o+Math.imul(R,ne)|0)+Math.imul(C,re)|0,i=i+Math.imul(C,ne)|0,n=n+Math.imul(N,ie)|0,o=(o=o+Math.imul(N,ae)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,ae)|0,n=n+Math.imul(O,ue)|0,o=(o=o+Math.imul(O,ce)|0)+Math.imul(j,ue)|0,i=i+Math.imul(j,ce)|0,n=n+Math.imul(M,le)|0,o=(o=o+Math.imul(M,de)|0)+Math.imul(A,le)|0,i=i+Math.imul(A,de)|0;var Te=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(o=(o=o+Math.imul(w,ye)|0)+Math.imul(S,pe)|0))<<13)|0;c=((i=i+Math.imul(S,ye)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(L,Q),o=(o=Math.imul(L,ee))+Math.imul(U,Q)|0,i=Math.imul(U,ee),n=n+Math.imul(I,re)|0,o=(o=o+Math.imul(I,ne)|0)+Math.imul(k,re)|0,i=i+Math.imul(k,ne)|0,n=n+Math.imul(R,ie)|0,o=(o=o+Math.imul(R,ae)|0)+Math.imul(C,ie)|0,i=i+Math.imul(C,ae)|0,n=n+Math.imul(N,ue)|0,o=(o=o+Math.imul(N,ce)|0)+Math.imul(P,ue)|0,i=i+Math.imul(P,ce)|0,n=n+Math.imul(O,le)|0,o=(o=o+Math.imul(O,de)|0)+Math.imul(j,le)|0,i=i+Math.imul(j,de)|0;var Ne=(c+(n=n+Math.imul(M,pe)|0)|0)+((8191&(o=(o=o+Math.imul(M,ye)|0)+Math.imul(A,pe)|0))<<13)|0;c=((i=i+Math.imul(A,ye)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(L,re),o=(o=Math.imul(L,ne))+Math.imul(U,re)|0,i=Math.imul(U,ne),n=n+Math.imul(I,ie)|0,o=(o=o+Math.imul(I,ae)|0)+Math.imul(k,ie)|0,i=i+Math.imul(k,ae)|0,n=n+Math.imul(R,ue)|0,o=(o=o+Math.imul(R,ce)|0)+Math.imul(C,ue)|0,i=i+Math.imul(C,ce)|0,n=n+Math.imul(N,le)|0,o=(o=o+Math.imul(N,de)|0)+Math.imul(P,le)|0,i=i+Math.imul(P,de)|0;var Pe=(c+(n=n+Math.imul(O,pe)|0)|0)+((8191&(o=(o=o+Math.imul(O,ye)|0)+Math.imul(j,pe)|0))<<13)|0;c=((i=i+Math.imul(j,ye)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(L,ie),o=(o=Math.imul(L,ae))+Math.imul(U,ie)|0,i=Math.imul(U,ae),n=n+Math.imul(I,ue)|0,o=(o=o+Math.imul(I,ce)|0)+Math.imul(k,ue)|0,i=i+Math.imul(k,ce)|0,n=n+Math.imul(R,le)|0,o=(o=o+Math.imul(R,de)|0)+Math.imul(C,le)|0,i=i+Math.imul(C,de)|0;var Be=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(o=(o=o+Math.imul(N,ye)|0)+Math.imul(P,pe)|0))<<13)|0;c=((i=i+Math.imul(P,ye)|0)+(o>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(L,ue),o=(o=Math.imul(L,ce))+Math.imul(U,ue)|0,i=Math.imul(U,ce),n=n+Math.imul(I,le)|0,o=(o=o+Math.imul(I,de)|0)+Math.imul(k,le)|0,i=i+Math.imul(k,de)|0;var Re=(c+(n=n+Math.imul(R,pe)|0)|0)+((8191&(o=(o=o+Math.imul(R,ye)|0)+Math.imul(C,pe)|0))<<13)|0;c=((i=i+Math.imul(C,ye)|0)+(o>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(L,le),o=(o=Math.imul(L,de))+Math.imul(U,le)|0,i=Math.imul(U,de);var Ce=(c+(n=n+Math.imul(I,pe)|0)|0)+((8191&(o=(o=o+Math.imul(I,ye)|0)+Math.imul(k,pe)|0))<<13)|0;c=((i=i+Math.imul(k,ye)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var xe=(c+(n=Math.imul(L,pe))|0)+((8191&(o=(o=Math.imul(L,ye))+Math.imul(U,pe)|0))<<13)|0;return c=((i=Math.imul(U,ye))+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,u[0]=me,u[1]=be,u[2]=ge,u[3]=ve,u[4]=we,u[5]=Se,u[6]=_e,u[7]=Me,u[8]=Ae,u[9]=Ee,u[10]=Oe,u[11]=je,u[12]=Te,u[13]=Ne,u[14]=Pe,u[15]=Be,u[16]=Re,u[17]=Ce,u[18]=xe,0!==c&&(u[19]=c,r.length++),r};function b(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,o=0,i=0;i<r.length-1;i++){var a=o;o=0;for(var s=67108863&n,u=Math.min(i,t.length-1),c=Math.max(0,i-e.length+1);c<=u;c++){var f=i-c,l=(0|e.words[f])*(0|t.words[c]),d=67108863&l;s=67108863&(d=d+s|0),o+=(a=(a=a+(l/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[i]=s,n=a,a=o}return 0!==n?r.words[i]=n:r.length--,r._strip()}function g(e,t,r){return b(e,t,r)}function v(e,t){this.x=e,this.y=t}Math.imul||(m=y),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?m(this,e,t):r<63?y(this,e,t):r<1024?b(this,e,t):g(this,e,t)},v.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n<e;n++)t[n]=this.revBin(n,r,e);return t},v.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var n=0,o=0;o<t;o++)n|=(1&e)<<t-o-1,e>>=1;return n},v.prototype.permute=function(e,t,r,n,o,i){for(var a=0;a<i;a++)n[a]=t[e[a]],o[a]=r[e[a]]},v.prototype.transform=function(e,t,r,n,o,i){this.permute(i,e,t,r,n,o);for(var a=1;a<o;a<<=1)for(var s=a<<1,u=Math.cos(2*Math.PI/s),c=Math.sin(2*Math.PI/s),f=0;f<o;f+=s)for(var l=u,d=c,h=0;h<a;h++){var p=r[f+h],y=n[f+h],m=r[f+h+a],b=n[f+h+a],g=l*m-d*b;b=l*b+d*m,m=g,r[f+h]=p+m,n[f+h]=y+b,r[f+h+a]=p-m,n[f+h+a]=y-b,h!==s&&(g=u*l-c*d,d=u*d+c*l,l=g)}},v.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),n=1&r,o=0;for(r=r/2|0;r;r>>>=1)o++;return 1<<o+1+n},v.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var n=0;n<r/2;n++){var o=e[n];e[n]=e[r-n-1],e[r-n-1]=o,o=t[n],t[n]=-t[r-n-1],t[r-n-1]=-o}},v.prototype.normalize13b=function(e,t){for(var r=0,n=0;n<t/2;n++){var o=8192*Math.round(e[2*n+1]/t)+Math.round(e[2*n]/t)+r;e[n]=67108863&o,r=o<67108864?0:o/67108864|0}return e},v.prototype.convert13b=function(e,t,r,o){for(var i=0,a=0;a<t;a++)i+=0|e[a],r[2*a]=8191&i,i>>>=13,r[2*a+1]=8191&i,i>>>=13;for(a=2*t;a<o;++a)r[a]=0;n(0===i),n(!(-8192&i))},v.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},v.prototype.mulp=function(e,t,r){var n=2*this.guessLen13b(e.length,t.length),o=this.makeRBT(n),i=this.stub(n),a=new Array(n),s=new Array(n),u=new Array(n),c=new Array(n),f=new Array(n),l=new Array(n),d=r.words;d.length=n,this.convert13b(e.words,e.length,a,n),this.convert13b(t.words,t.length,c,n),this.transform(a,i,s,u,n,o),this.transform(c,i,f,l,n,o);for(var h=0;h<n;h++){var p=s[h]*f[h]-u[h]*l[h];u[h]=s[h]*l[h]+u[h]*f[h],s[h]=p}return this.conjugate(s,u,n),this.transform(s,u,d,i,n,o),this.conjugate(d,i,n),this.normalize13b(d,n),r.negative=e.negative^t.negative,r.length=e.length+t.length,r._strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),g(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n("number"==typeof e),n(e<67108864);for(var r=0,o=0;o<this.length;o++){var i=(0|this.words[o])*e,a=(67108863&i)+(67108863&r);r>>=26,r+=i/67108864|0,r+=a>>>26,this.words[o]=67108863&a}return 0!==r&&(this.words[o]=r,this.length++),t?this.ineg():this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,o=r%26;t[r]=e.words[n]>>>o&1}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n<t.length&&0===t[n];n++,r=r.sqr());if(++n<t.length)for(var o=r.sqr();n<t.length;n++,o=o.sqr())0!==t[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,o=(e-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t<this.length;t++){var s=this.words[t]&i,u=(0|this.words[t])-s<<r;this.words[t]=u|a,a=s>>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this._strip()},i.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},i.prototype.iushrn=function(e,t,r){var o;n("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<<i,u=r;if(o-=a,o=Math.max(0,o),u){for(var c=0;c<a;c++)u.words[c]=this.words[c];u.length=a}if(0===a);else if(this.length>a)for(this.length-=a,c=0;c<this.length;c++)this.words[c]=this.words[c+a];else this.words[0]=0,this.length=1;var f=0;for(c=this.length-1;c>=0&&(0!==f||c>=o);c--){var l=0|this.words[c];this.words[c]=f<<26-i|l>>>i,f=l&s}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,o=1<<t;return!(this.length<=r||!(this.words[r]&o))},i.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return this._strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,r){var o,i,a=e.length+r;this._expand(a);var s=0;for(o=0;o<e.length;o++){i=(0|this.words[o+r])+s;var u=(0|e.words[o])*t;s=((i-=67108863&u)>>26)-(u/67108864|0),this.words[o+r]=67108863&i}for(;o<this.length-r;o++)s=(i=(0|this.words[o+r])+s)>>26,this.words[o+r]=67108863&i;if(0===s)return this._strip();for(n(-1===s),s=0,o=0;o<this.length;o++)s=(i=-(0|this.words[o])+s)>>26,this.words[o]=67108863&i;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!=(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c<s.length;c++)s.words[c]=0}var f=n.clone()._ishlnsubmul(o,1,u);0===f.negative&&(n=f,s&&(s.words[u]=1));for(var l=u-1;l>=0;l--){var d=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(o,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=d)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):this.negative&e.negative?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modrn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),o=e.andln(1),i=r.cmp(n);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,o=0,i=this.length-1;i>=0;i--)o=(r*o+(0|this.words[i]))%e;return t?-o:o},i.prototype.modn=function(e){return this.modrn(e)},i.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*r;this.words[o]=i/e|0,r=i%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),l=t.clone();!t.isZero();){for(var d=0,h=1;!(t.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(f),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,y=1;!(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(f),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(s),a.isub(u)):(r.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},i.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;!(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,d=1;!(r.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var o=t.cmp(r);if(o<0){var i=t;t=r,r=i}else if(0===o||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,o=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=o,this;for(var i=o,a=r;0!==i&&a<this.length;a++){var s=0|this.words[a];i=(s+=i)>>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},i.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],o=0|e.words[r];if(n!==o){n<o?t=-1:n>o&&(t=1);break}}return t},i.prototype.gtn=function(e){retu