var PS={};(function(exports){"use strict";exports.arrayApply=function(fs){return function(xs){var l=fs.length;var k=xs.length;var result=new Array(l*k);var n=0;for(var i=0;i<l;i++){var f=fs[i];for(var j=0;j<k;j++){result[n++]=f(xs[j])}}return result}}})(PS["Control.Apply"]=PS["Control.Apply"]||{});(function(exports){"use strict";var otherwise=true;exports["otherwise"]=otherwise})(PS["Data.Boolean"]=PS["Data.Boolean"]||{});(function(exports){"use strict";exports.refEq=function(r1){return function(r2){return r1===r2}}})(PS["Data.Eq"]=PS["Data.Eq"]||{});(function(exports){"use strict";exports.unit={}})(PS["Data.Unit"]=PS["Data.Unit"]||{});(function(exports){"use strict";exports.showIntImpl=function(n){return n.toString()}})(PS["Data.Show"]=PS["Data.Show"]||{});(function(exports){"use strict";var $foreign=PS["Data.Show"];var Data_Symbol=PS["Data.Symbol"];var Record_Unsafe=PS["Record.Unsafe"];var Type_Data_RowList=PS["Type.Data.RowList"];var Show=function(show){this.show=show};var showInt=new Show($foreign.showIntImpl);var show=function(dict){return dict.show};exports["Show"]=Show;exports["show"]=show;exports["showInt"]=showInt})(PS["Data.Show"]=PS["Data.Show"]||{});(function(exports){"use strict";var $foreign=PS["Data.Unit"];var Data_Show=PS["Data.Show"];exports["unit"]=$foreign.unit})(PS["Data.Unit"]=PS["Data.Unit"]||{});(function(exports){"use strict";var $foreign=PS["Data.Eq"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Symbol=PS["Data.Symbol"];var Data_Unit=PS["Data.Unit"];var Data_Void=PS["Data.Void"];var Record_Unsafe=PS["Record.Unsafe"];var Type_Data_RowList=PS["Type.Data.RowList"];var Eq=function(eq){this.eq=eq};var eqInt=new Eq($foreign.refEq);var eq=function(dict){return dict.eq};exports["Eq"]=Eq;exports["eq"]=eq;exports["eqInt"]=eqInt})(PS["Data.Eq"]=PS["Data.Eq"]||{});(function(exports){"use strict";exports.unsafeCompareImpl=function(lt){return function(eq){return function(gt){return function(x){return function(y){return x<y?lt:x===y?eq:gt}}}}}})(PS["Data.Ord.Unsafe"]=PS["Data.Ord.Unsafe"]||{});(function(exports){"use strict";var Data_Eq=PS["Data.Eq"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var LT=function(){function LT(){}LT.value=new LT;return LT}();var GT=function(){function GT(){}GT.value=new GT;return GT}();var EQ=function(){function EQ(){}EQ.value=new EQ;return EQ}();exports["LT"]=LT;exports["GT"]=GT;exports["EQ"]=EQ})(PS["Data.Ordering"]=PS["Data.Ordering"]||{});(function(exports){"use strict";var $foreign=PS["Data.Ord.Unsafe"];var Data_Ordering=PS["Data.Ordering"];var unsafeCompare=$foreign.unsafeCompareImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value);exports["unsafeCompare"]=unsafeCompare})(PS["Data.Ord.Unsafe"]=PS["Data.Ord.Unsafe"]||{});(function(exports){"use strict";var $foreign=PS["Data.Semiring"];var Data_Symbol=PS["Data.Symbol"];var Data_Unit=PS["Data.Unit"];var Record_Unsafe=PS["Record.Unsafe"];var Type_Data_Row=PS["Type.Data.Row"];var Type_Data_RowList=PS["Type.Data.RowList"];var Semiring=function(add,mul,one,zero){this.add=add;this.mul=mul;this.one=one;this.zero=zero};var zero=function(dict){return dict.zero};var one=function(dict){return dict.one};var mul=function(dict){return dict.mul};var add=function(dict){return dict.add};exports["Semiring"]=Semiring;exports["add"]=add;exports["zero"]=zero;exports["mul"]=mul;exports["one"]=one})(PS["Data.Semiring"]=PS["Data.Semiring"]||{});(function(exports){"use strict";var $foreign=PS["Data.Ord"];var Data_Eq=PS["Data.Eq"];var Data_Ord_Unsafe=PS["Data.Ord.Unsafe"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Semiring=PS["Data.Semiring"];var Data_Symbol=PS["Data.Symbol"];var Data_Unit=PS["Data.Unit"];var Data_Void=PS["Data.Void"];var Record_Unsafe=PS["Record.Unsafe"];var Type_Data_RowList=PS["Type.Data.RowList"];var Ord=function(Eq0,compare){this.Eq0=Eq0;this.compare=compare};var ordInt=new Ord(function(){return Data_Eq.eqInt},Data_Ord_Unsafe.unsafeCompare);var compare=function(dict){return dict.compare};var comparing=function(dictOrd){return function(f){return function(x){return function(y){return compare(dictOrd)(f(x))(f(y))}}}};exports["Ord"]=Ord;exports["compare"]=compare;exports["comparing"]=comparing;exports["ordInt"]=ordInt})(PS["Data.Ord"]=PS["Data.Ord"]||{});(function(exports){"use strict";var Control_Category=PS["Control.Category"];var Data_Boolean=PS["Data.Boolean"];var Data_Ord=PS["Data.Ord"];var Data_Ring=PS["Data.Ring"];var flip=function(f){return function(b){return function(a){return f(a)(b)}}};exports["flip"]=flip})(PS["Data.Function"]=PS["Data.Function"]||{});(function(exports){"use strict";exports.arrayMap=function(f){return function(arr){var l=arr.length;var result=new Array(l);for(var i=0;i<l;i++){result[i]=f(arr[i])}return result}}})(PS["Data.Functor"]=PS["Data.Functor"]||{});(function(exports){"use strict";var $foreign=PS["Data.Functor"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Function=PS["Data.Function"];var Data_Unit=PS["Data.Unit"];var Functor=function(map){this.map=map};var map=function(dict){return dict.map};var functorArray=new Functor($foreign.arrayMap);exports["Functor"]=Functor;exports["map"]=map;exports["functorArray"]=functorArray})(PS["Data.Functor"]=PS["Data.Functor"]||{});(function(exports){"use strict";var $foreign=PS["Control.Apply"];var Control_Category=PS["Control.Category"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Apply=function(Functor0,apply){this.Functor0=Functor0;this.apply=apply};var applyArray=new Apply(function(){return Data_Functor.functorArray},$foreign.arrayApply);var apply=function(dict){return dict.apply};exports["Apply"]=Apply;exports["apply"]=apply;exports["applyArray"]=applyArray})(PS["Control.Apply"]=PS["Control.Apply"]||{});(function(exports){"use strict";var Control_Apply=PS["Control.Apply"];var Data_Functor=PS["Data.Functor"];var Data_Unit=PS["Data.Unit"];var Applicative=function(Apply0,pure){this.Apply0=Apply0;this.pure=pure};var pure=function(dict){return dict.pure};exports["Applicative"]=Applicative;exports["pure"]=pure})(PS["Control.Applicative"]=PS["Control.Applicative"]||{});(function(exports){"use strict";exports.arrayBind=function(arr){return function(f){var result=[];for(var i=0,l=arr.length;i<l;i++){Array.prototype.push.apply(result,f(arr[i]))}return result}}})(PS["Control.Bind"]=PS["Control.Bind"]||{});(function(exports){"use strict";var $foreign=PS["Control.Bind"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Category=PS["Control.Category"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Unit=PS["Data.Unit"];var Bind=function(Apply0,bind){this.Apply0=Apply0;this.bind=bind};var Discard=function(discard){this.discard=discard};var discard=function(dict){return dict.discard};var bindArray=new Bind(function(){return Control_Apply.applyArray},$foreign.arrayBind);var bind=function(dict){return dict.bind};var discardUnit=new Discard(function(dictBind){return bind(dictBind)});exports["Bind"]=Bind;exports["bind"]=bind;exports["Discard"]=Discard;exports["discard"]=discard;exports["bindArray"]=bindArray;exports["discardUnit"]=discardUnit})(PS["Control.Bind"]=PS["Control.Bind"]||{});(function(exports){"use strict";var Control_Alt=PS["Control.Alt"];var Control_Alternative=PS["Control.Alternative"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Category=PS["Control.Category"];var Control_Extend=PS["Control.Extend"];var Control_Monad=PS["Control.Monad"];var Control_MonadZero=PS["Control.MonadZero"];var Control_Plus=PS["Control.Plus"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_Monoid=PS["Data.Monoid"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var Data_Unit=PS["Data.Unit"];var Prelude=PS["Prelude"];var Nothing=function(){function Nothing(){}Nothing.value=new Nothing;return Nothing}();var Just=function(){function Just(value0){this.value0=value0}Just.create=function(value0){return new Just(value0)};return Just}();var maybe=function(v){return function(v1){return function(v2){if(v2 instanceof Nothing){return v}if(v2 instanceof Just){return v1(v2.value0)}throw new Error("Failed pattern match at Data.Maybe (line 217, column 1 - line 217, column 51): "+[v.constructor.name,v1.constructor.name,v2.constructor.name])}}};var functorMaybe=new Data_Functor.Functor(function(v){return function(v1){if(v1 instanceof Just){return new Just(v(v1.value0))}return Nothing.value}});var applyMaybe=new Control_Apply.Apply(function(){return functorMaybe},function(v){return function(v1){if(v instanceof Just){return Data_Functor.map(functorMaybe)(v.value0)(v1)}if(v instanceof Nothing){return Nothing.value}throw new Error("Failed pattern match at Data.Maybe (line 67, column 1 - line 67, column 35): "+[v.constructor.name,v1.constructor.name])}});var bindMaybe=new Control_Bind.Bind(function(){return applyMaybe},function(v){return function(v1){if(v instanceof Just){return v1(v.value0)}if(v instanceof Nothing){return Nothing.value}throw new Error("Failed pattern match at Data.Maybe (line 125, column 1 - line 125, column 33): "+[v.constructor.name,v1.constructor.name])}});var applicativeMaybe=new Control_Applicative.Applicative(function(){return applyMaybe},Just.create);exports["Nothing"]=Nothing;exports["Just"]=Just;exports["maybe"]=maybe;exports["functorMaybe"]=functorMaybe;exports["applyMaybe"]=applyMaybe;exports["applicativeMaybe"]=applicativeMaybe;exports["bindMaybe"]=bindMaybe})(PS["Data.Maybe"]=PS["Data.Maybe"]||{});(function(exports){"use strict";var Control_Alt=PS["Control.Alt"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Extend=PS["Control.Extend"];var Control_Monad=PS["Control.Monad"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Bifoldable=PS["Data.Bifoldable"];var Data_Bifunctor=PS["Data.Bifunctor"];var Data_Bitraversable=PS["Data.Bitraversable"];var Data_Bounded=PS["Data.Bounded"];var Data_Eq=PS["Data.Eq"];var Data_Foldable=PS["Data.Foldable"];var Data_FoldableWithIndex=PS["Data.FoldableWithIndex"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_FunctorWithIndex=PS["Data.FunctorWithIndex"];var Data_Maybe=PS["Data.Maybe"];var Data_Monoid=PS["Data.Monoid"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var Data_Traversable=PS["Data.Traversable"];var Data_TraversableWithIndex=PS["Data.TraversableWithIndex"];var Data_Unit=PS["Data.Unit"];var Prelude=PS["Prelude"];var Left=function(){function Left(value0){this.value0=value0}Left.create=function(value0){return new Left(value0)};return Left}();var Right=function(){function Right(value0){this.value0=value0}Right.create=function(value0){return new Right(value0)};return Right}();var note=function(a){return Data_Maybe.maybe(new Left(a))(Right.create)};var functorEither=new Data_Functor.Functor(function(f){return function(m){if(m instanceof Left){return new Left(m.value0)}if(m instanceof Right){return new Right(f(m.value0))}throw new Error("Failed pattern match at Data.Either (line 38, column 8 - line 38, column 52): "+[m.constructor.name])}});var either=function(v){return function(v1){return function(v2){if(v2 instanceof Left){return v(v2.value0)}if(v2 instanceof Right){return v1(v2.value0)}throw new Error("Failed pattern match at Data.Either (line 238, column 1 - line 238, column 64): "+[v.constructor.name,v1.constructor.name,v2.constructor.name])}}};var applyEither=new Control_Apply.Apply(function(){return functorEither},function(v){return function(v1){if(v instanceof Left){return new Left(v.value0)}if(v instanceof Right){return Data_Functor.map(functorEither)(v.value0)(v1)}throw new Error("Failed pattern match at Data.Either (line 82, column 1 - line 82, column 41): "+[v.constructor.name,v1.constructor.name])}});var bindEither=new Control_Bind.Bind(function(){return applyEither},either(function(e){return function(v){return new Left(e)}})(function(a){return function(f){return f(a)}}));var applicativeEither=new Control_Applicative.Applicative(function(){return applyEither},Right.create);exports["Left"]=Left;exports["Right"]=Right;exports["either"]=either;exports["note"]=note;exports["functorEither"]=functorEither;exports["applyEither"]=applyEither;exports["applicativeEither"]=applicativeEither;exports["bindEither"]=bindEither})(PS["Data.Either"]=PS["Data.Either"]||{});(function(exports){"use strict";exports.unsafePartial=function(f){return f()}})(PS["Partial.Unsafe"]=PS["Partial.Unsafe"]||{});(function(exports){"use strict";exports.crashWith=function(){return function(msg){throw new Error(msg)}}})(PS["Partial"]=PS["Partial"]||{});(function(exports){"use strict";var $foreign=PS["Partial"];exports["crashWith"]=$foreign.crashWith})(PS["Partial"]=PS["Partial"]||{});(function(exports){"use strict";var $foreign=PS["Partial.Unsafe"];var Partial=PS["Partial"];var unsafeCrashWith=function(msg){return $foreign.unsafePartial(function(dictPartial){return Partial.crashWith(dictPartial)(msg)})};exports["unsafeCrashWith"]=unsafeCrashWith})(PS["Partial.Unsafe"]=PS["Partial.Unsafe"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Bind=PS["Control.Bind"];var Control_Monad=PS["Control.Monad"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Bifunctor=PS["Data.Bifunctor"];var Data_Either=PS["Data.Either"];var Data_Functor=PS["Data.Functor"];var Data_Identity=PS["Data.Identity"];var Data_Maybe=PS["Data.Maybe"];var Data_Unit=PS["Data.Unit"];var Effect=PS["Effect"];var Effect_Ref=PS["Effect.Ref"];var Partial_Unsafe=PS["Partial.Unsafe"];var Prelude=PS["Prelude"];var Loop=function(){function Loop(value0){this.value0=value0}Loop.create=function(value0){return new Loop(value0)};return Loop}();var Done=function(){function Done(value0){this.value0=value0}Done.create=function(value0){return new Done(value0)};return Done}();var tailRec=function(f){var go=function($copy_v){var $tco_done=false;var $tco_result;function $tco_loop(v){if(v instanceof Loop){$copy_v=f(v.value0);return}if(v instanceof Done){$tco_done=true;return v.value0}throw new Error("Failed pattern match at Control.Monad.Rec.Class (line 91, column 3 - line 91, column 25): "+[v.constructor.name])}while(!$tco_done){$tco_result=$tco_loop($copy_v)}return $tco_result};return function($53){return go(f($53))}};exports["Loop"]=Loop;exports["Done"]=Done;exports["tailRec"]=tailRec})(PS["Control.Monad.Rec.Class"]=PS["Control.Monad.Rec.Class"]||{});(function(exports){"use strict";exports.length=function(xs){return xs.length};exports.indexImpl=function(just){return function(nothing){return function(xs){return function(i){return i<0||i>=xs.length?nothing:just(xs[i])}}}};exports.sortImpl=function(f){return function(l){return l.slice().sort(function(x,y){return f(x)(y)})}};exports.slice=function(s){return function(e){return function(l){return l.slice(s,e)}}};exports.drop=function(n){return function(l){return n<1?l:l.slice(n)}}})(PS["Data.Array"]=PS["Data.Array"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Biapplicative=PS["Control.Biapplicative"];var Control_Biapply=PS["Control.Biapply"];var Control_Bind=PS["Control.Bind"];var Control_Comonad=PS["Control.Comonad"];var Control_Extend=PS["Control.Extend"];var Control_Lazy=PS["Control.Lazy"];var Control_Monad=PS["Control.Monad"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Bifoldable=PS["Data.Bifoldable"];var Data_Bifunctor=PS["Data.Bifunctor"];var Data_Bitraversable=PS["Data.Bitraversable"];var Data_BooleanAlgebra=PS["Data.BooleanAlgebra"];var Data_Bounded=PS["Data.Bounded"];var Data_CommutativeRing=PS["Data.CommutativeRing"];var Data_Distributive=PS["Data.Distributive"];var Data_Eq=PS["Data.Eq"];var Data_Foldable=PS["Data.Foldable"];var Data_FoldableWithIndex=PS["Data.FoldableWithIndex"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_Functor_Invariant=PS["Data.Functor.Invariant"];var Data_FunctorWithIndex=PS["Data.FunctorWithIndex"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Maybe=PS["Data.Maybe"];var Data_Maybe_First=PS["Data.Maybe.First"];var Data_Monoid=PS["Data.Monoid"];var Data_Newtype=PS["Data.Newtype"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Semigroup_Foldable=PS["Data.Semigroup.Foldable"];var Data_Semigroup_Traversable=PS["Data.Semigroup.Traversable"];var Data_Semiring=PS["Data.Semiring"];var Data_Show=PS["Data.Show"];var Data_Traversable=PS["Data.Traversable"];var Data_TraversableWithIndex=PS["Data.TraversableWithIndex"];var Data_Unit=PS["Data.Unit"];var Prelude=PS["Prelude"];var Type_Equality=PS["Type.Equality"];var Tuple=function(){function Tuple(value0,value1){this.value0=value0;this.value1=value1}Tuple.create=function(value0){return function(value1){return new Tuple(value0,value1)}};return Tuple}();var fst=function(v){return v.value0};exports["Tuple"]=Tuple;exports["fst"]=fst})(PS["Data.Tuple"]=PS["Data.Tuple"]||{});(function(exports){"use strict";exports.unsafeCoerce=function(x){return x}})(PS["Unsafe.Coerce"]=PS["Unsafe.Coerce"]||{});(function(exports){"use strict";var $foreign=PS["Unsafe.Coerce"];exports["unsafeCoerce"]=$foreign.unsafeCoerce})(PS["Unsafe.Coerce"]=PS["Unsafe.Coerce"]||{});(function(exports){"use strict";var $foreign=PS["Data.Array"];var Control_Alt=PS["Control.Alt"];var Control_Alternative=PS["Control.Alternative"];var Control_Applicative=PS["Control.Applicative"];var Control_Apply=PS["Control.Apply"];var Control_Bind=PS["Control.Bind"];var Control_Category=PS["Control.Category"];var Control_Lazy=PS["Control.Lazy"];var Control_Monad_Rec_Class=PS["Control.Monad.Rec.Class"];var Control_Monad_ST=PS["Control.Monad.ST"];var Control_Monad_ST_Internal=PS["Control.Monad.ST.Internal"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Array_NonEmpty_Internal=PS["Data.Array.NonEmpty.Internal"];var Data_Array_ST=PS["Data.Array.ST"];var Data_Array_ST_Iterator=PS["Data.Array.ST.Iterator"];var Data_Boolean=PS["Data.Boolean"];var Data_Eq=PS["Data.Eq"];var Data_Foldable=PS["Data.Foldable"];var Data_Function=PS["Data.Function"];var Data_Functor=PS["Data.Functor"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Maybe=PS["Data.Maybe"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Semiring=PS["Data.Semiring"];var Data_Traversable=PS["Data.Traversable"];var Data_Tuple=PS["Data.Tuple"];var Data_Unfoldable=PS["Data.Unfoldable"];var Partial_Unsafe=PS["Partial.Unsafe"];var Prelude=PS["Prelude"];var Unsafe_Coerce=PS["Unsafe.Coerce"];var sortBy=function(comp){return function(xs){var comp$prime=function(x){return function(y){var v=comp(x)(y);if(v instanceof Data_Ordering.GT){return 1}if(v instanceof Data_Ordering.EQ){return 0}if(v instanceof Data_Ordering.LT){return-1|0}throw new Error("Failed pattern match at Data.Array (line 702, column 15 - line 707, column 1): "+[v.constructor.name])}};return $foreign.sortImpl(comp$prime)(xs)}};var sortWith=function(dictOrd){return function(f){return sortBy(Data_Ord.comparing(dictOrd)(f))}};var singleton=function(a){return[a]};var index=$foreign.indexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);var head=function(xs){return index(xs)(0)};var concatMap=Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray));var mapMaybe=function(f){return concatMap(function($114){return Data_Maybe.maybe([])(singleton)(f($114))})};exports["singleton"]=singleton;exports["head"]=head;exports["index"]=index;exports["concatMap"]=concatMap;exports["mapMaybe"]=mapMaybe;exports["sortBy"]=sortBy;exports["sortWith"]=sortWith;exports["length"]=$foreign.length;exports["drop"]=$foreign.drop})(PS["Data.Array"]=PS["Data.Array"]||{});(function(exports){"use strict";exports.fromStringAsImpl=function(just){return function(nothing){return function(radix){var digits;if(radix<11){digits="[0-"+(radix-1).toString()+"]"}else if(radix===11){digits="[0-9a]"}else{digits="[0-9a-"+String.fromCharCode(86+radix)+"]"}var pattern=new RegExp("^[\\+\\-]?"+digits+"+$","i");return function(s){if(pattern.test(s)){var i=parseInt(s,radix);return(i|0)===i?just(i):nothing}else{return nothing}}}}}})(PS["Data.Int"]=PS["Data.Int"]||{});(function(exports){"use strict";var $foreign=PS["Data.Int"];var Control_Category=PS["Control.Category"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Boolean=PS["Data.Boolean"];var Data_Bounded=PS["Data.Bounded"];var Data_CommutativeRing=PS["Data.CommutativeRing"];var Data_DivisionRing=PS["Data.DivisionRing"];var Data_Eq=PS["Data.Eq"];var Data_EuclideanRing=PS["Data.EuclideanRing"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Int_Bits=PS["Data.Int.Bits"];var Data_Maybe=PS["Data.Maybe"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Semiring=PS["Data.Semiring"];var Data_Show=PS["Data.Show"];var Global=PS["Global"];var $$Math=PS["Math"];var Prelude=PS["Prelude"];var fromStringAs=$foreign.fromStringAsImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);var fromString=fromStringAs(10);var decimal=10;exports["fromString"]=fromString;exports["decimal"]=decimal;exports["fromStringAs"]=fromStringAs})(PS["Data.Int"]=PS["Data.Int"]||{});(function(exports){exports.numberBitsToInt=function(x){return x|0};var Long=require("long");function RadixChecker(radix){var digits;if(radix<11){digits="[0-"+(radix-1).toString()+"]"}else if(radix===11){digits="[0-9a]"}else{digits="[0-9a-"+String.fromCharCode(86+radix)+"]"}this.baseRE=new RegExp("^"+digits+"+$","i");this.maxNegSignedBase=Long.MIN_VALUE.toString(radix).substring(1);this.maxPosSignedBase=Long.MAX_VALUE.toString(radix);this.maxUnsignedBase=Long.MAX_UNSIGNED_VALUE.toString(radix)}function hasValidDigits(isNegative,isUnsigned,base,radix){radixCheckers[radix]=radixCheckers[radix]||new RadixChecker(radix);var rc=radixCheckers[radix];var maxBase;if(isUnsigned){maxBase=rc.maxUnsignedBase}else if(isNegative){maxBase=rc.maxNegSignedBase}else{maxBase=rc.maxPosSignedBase}return(base.length<maxBase.length||base.length===maxBase.length&&base<=maxBase)&&rc.baseRE.test(base)}})(PS["Data.Long.Internal"]=PS["Data.Long.Internal"]||{});(function(exports){var L=require("long");exports.uzero=L.UZERO;exports.uone=L.UONE;exports.fromInt=L.fromInt;exports.add=function(l){return l.add.bind(l)};exports.getHighBits=function(l){return l.getHighBits()};exports.getLowBits=function(l){return l.getLowBits()};exports.multiply=function(l){return l.multiply.bind(l)};exports.toString=function(l){return l.toString.bind(l)}})(PS["Data.Long.FFI"]=PS["Data.Long.FFI"]||{});(function(exports){"use strict";var $foreign=PS["Data.Long.FFI"];var Data_Eq=PS["Data.Eq"];var Data_Function_Uncurried=PS["Data.Function.Uncurried"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Int=PS["Data.Int"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Show=PS["Data.Show"];var Effect_Uncurried=PS["Effect.Uncurried"];var Foreign=PS["Foreign"];var Prelude=PS["Prelude"];exports["uzero"]=$foreign.uzero;exports["uone"]=$foreign.uone;exports["fromInt"]=$foreign.fromInt;exports["add"]=$foreign.add;exports["getHighBits"]=$foreign.getHighBits;exports["getLowBits"]=$foreign.getLowBits;exports["multiply"]=$foreign.multiply;exports["toString"]=$foreign.toString})(PS["Data.Long.FFI"]=PS["Data.Long.FFI"]||{});(function(exports){"use strict";var $foreign=PS["Data.Long.Internal"];var Control_Apply=PS["Control.Apply"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_Boolean=PS["Data.Boolean"];var Data_Bounded=PS["Data.Bounded"];var Data_CommutativeRing=PS["Data.CommutativeRing"];var Data_Eq=PS["Data.Eq"];var Data_EuclideanRing=PS["Data.EuclideanRing"];var Data_Function=PS["Data.Function"];var Data_Function_Uncurried=PS["Data.Function.Uncurried"];var Data_Functor=PS["Data.Functor"];var Data_HeytingAlgebra=PS["Data.HeytingAlgebra"];var Data_Int=PS["Data.Int"];var Data_Long_FFI=PS["Data.Long.FFI"];var Data_Maybe=PS["Data.Maybe"];var Data_Nullable=PS["Data.Nullable"];var Data_Ord=PS["Data.Ord"];var Data_Ordering=PS["Data.Ordering"];var Data_Ring=PS["Data.Ring"];var Data_Semiring=PS["Data.Semiring"];var Data_Show=PS["Data.Show"];var Prelude=PS["Prelude"];var Test_QuickCheck=PS["Test.QuickCheck"];var Test_QuickCheck_Arbitrary=PS["Test.QuickCheck.Arbitrary"];var Test_QuickCheck_Gen=PS["Test.QuickCheck.Gen"];var SignProxy=function(){function SignProxy(){}SignProxy.value=new SignProxy;return SignProxy}();var Long=function(x){return x};var SInfo=function(ffiSignedness,toInt){this.ffiSignedness=ffiSignedness;this.toInt=toInt};var toStringAs=function(r){return function(v){return Data_Long_FFI.toString(v)(r)}};var toString=toStringAs(Data_Int.decimal);var toInt=function(dict){return dict.toInt};var semiringLongUnsigned=new Data_Semiring.Semiring(function(v){return function(v1){return Long(Data_Long_FFI.add(v)(v1))}},function(v){return function(v1){return Long(Data_Long_FFI.multiply(v)(v1))}},Long(Data_Long_FFI.uone),Long(Data_Long_FFI.uzero));var lowBits=function(v){return $foreign.numberBitsToInt(Data_Long_FFI.getLowBits(v))};var highBits=function(v){return $foreign.numberBitsToInt(Data_Long_FFI.getHighBits(v))};var infoUnsigned=new SInfo(function(v){return true},function(l){var low=lowBits(l);var high=highBits(l);var $94=high===0&&low>0;if($94){return new Data_Maybe.Just(low)}return Data_Maybe.Nothing.value});var ffiSignedness=function(dict){return dict.ffiSignedness};var unsafeFromInt=function(dictSInfo){return function(i){return Long(Data_Long_FFI.fromInt(i,ffiSignedness(dictSInfo)(SignProxy.value)))}};var unsignedLongFromInt=function(i){if(i>=0){return Data_Maybe.Just.create(unsafeFromInt(infoUnsigned)(i))}if(Data_Boolean.otherwise){return Data_Maybe.Nothing.value}throw new Error("Failed pattern match at Data.Long.Internal (line 150, column 1 - line 150, column 52): "+[i.constructor.name])};exports["SInfo"]=SInfo;exports["ffiSignedness"]=ffiSignedness;exports["toInt"]=toInt;exports["SignProxy"]=SignProxy;exports["unsignedLongFromInt"]=unsignedLongFromInt;exports["unsafeFromInt"]=unsafeFromInt;exports["highBits"]=highBits;exports["lowBits"]=lowBits;exports["toString"]=toString;exports["toStringAs"]=toStringAs;exports["infoUnsigned"]=infoUnsigned;exports["semiringLongUnsigned"]=semiringLongUnsigned})(PS["Data.Long.Internal"]=PS["Data.Long.Internal"]||{});(function(exports){"use strict";var Data_Int=PS["Data.Int"];var Data_Long_Internal=PS["Data.Long.Internal"];var Data_Maybe=PS["Data.Maybe"];var toString=Data_Long_Internal.toString;var fromInt=Data_Long_Internal.unsignedLongFromInt;exports["fromInt"]=fromInt;exports["toString"]=toString})(PS["Data.Long.Unsigned"]=PS["Data.Long.Unsigned"]||{});(function(exports){"use strict";exports.split=function(sep){return function(s){return s.split(sep)}};exports.trim=function(s){return s.trim()}})(PS["Data.String.Common"]=PS["Data.String.Common"]||{});(function(exports){"use strict";var $foreign=PS["Data.String.Common"];var Data_Eq=PS["Data.Eq"];var Data_Ordering=PS["Data.Ordering"];var Data_String_Pattern=PS["Data.String.Pattern"];var Prelude=PS["Prelude"];exports["split"]=$foreign.split;exports["trim"]=$foreign.trim})(PS["Data.String.Common"]=PS["Data.String.Common"]||{});(function(exports){"use strict";var Control_Applicative=PS["Control.Applicative"];var Control_Bind=PS["Control.Bind"];var Control_Monad_Rec_Class=PS["Control.Monad.Rec.Class"];var Data_Array=PS["Data.Array"];var Data_Either=PS["Data.Either"];var Data_Eq=PS["Data.Eq"];var Data_Int=PS["Data.Int"];var Data_Long_Internal=PS["Data.Long.Internal"];var Data_Long_Unsigned=PS["Data.Long.Unsigned"];var Data_Maybe=PS["Data.Maybe"];var Data_Ord=PS["Data.Ord"];var Data_Ring=PS["Data.Ring"];var Data_Semigroup=PS["Data.Semigroup"];var Data_Semiring=PS["Data.Semiring"];var Data_Show=PS["Data.Show"];var Data_String=PS["Data.String"];var Data_String_Common=PS["Data.String.Common"];var Data_String_Pattern=PS["Data.String.Pattern"];var Data_Tuple=PS["Data.Tuple"];var Data_Unit=PS["Data.Unit"];var Partial_Unsafe=PS["Partial.Unsafe"];var Prelude=PS["Prelude"];var solve$prime$prime=function(m){return function(abs){var unsafeFromInt=function(i){var v=Data_Long_Unsigned.fromInt(i);if(v instanceof Data_Maybe.Nothing){return Partial_Unsafe.unsafeCrashWith("Longs.fromInt "+Data_Show.show(Data_Show.showInt)(i))}if(v instanceof Data_Maybe.Just){return v.value0}throw new Error("Failed pattern match at AtCoder.ABC121.C (line 59, column 7 - line 61, column 20): "+[v.constructor.name])};var sorted=Data_Array.sortWith(Data_Ord.ordInt)(Data_Tuple.fst)(abs);var go=function(v){var v1=Data_Array.index(sorted)(v.i);if(v1 instanceof Data_Maybe.Nothing){return new Control_Monad_Rec_Class.Done(v.n)}if(v1 instanceof Data_Maybe.Just){var m$prime$prime=v["m'"]-v1.value0.value1|0;var a$prime=unsafeFromInt(v1.value0.value0);var $19=m$prime$prime<0;if($19){return new Control_Monad_Rec_Class.Done(Data_Semiring.add(Data_Long_Internal.semiringLongUnsigned)(v.n)(Data_Semiring.mul(Data_Long_Internal.semiringLongUnsigned)(a$prime)(unsafeFromInt(v["m'"]))))}return new Control_Monad_Rec_Class.Loop({i:v.i+1|0,"m'":m$prime$prime,n:Data_Semiring.add(Data_Long_Internal.semiringLongUnsigned)(v.n)(Data_Semiring.mul(Data_Long_Internal.semiringLongUnsigned)(a$prime)(unsafeFromInt(v1.value0.value1)))})}throw new Error("Failed pattern match at AtCoder.ABC121.C (line 63, column 7 - line 75, column 74): "+[v1.constructor.name])};return Control_Monad_Rec_Class.tailRec(go)({i:0,"m'":m,n:Data_Semiring.zero(Data_Long_Internal.semiringLongUnsigned)})}};var solve$prime=function(input){var lines=Data_String_Common.split("\n")(Data_String_Common.trim(input));return Control_Bind.bind(Data_Either.bindEither)(Control_Bind.bind(Data_Either.bindEither)(Data_Either.note("nms")(Data_Array.head(lines)))(function(v){return Control_Bind.bind(Data_Either.bindEither)(Control_Applicative.pure(Data_Either.applicativeEither)(Data_Array.drop(1)(lines)))(function(v1){return Control_Applicative.pure(Data_Either.applicativeEither)({abss:v1,nms:v})})}))(function(v){return Control_Bind.bind(Data_Either.bindEither)(function(){var v1=Data_String_Common.split(" ")(v.nms);if(v1.length===2){return Control_Bind.bind(Data_Either.bindEither)(Data_Either.note("n")(Data_Int.fromString(v1[0])))(function(v2){return Control_Bind.bind(Data_Either.bindEither)(Data_Either.note("m")(Data_Int.fromString(v1[1])))(function(v3){return Control_Applicative.pure(Data_Either.applicativeEither)({m:v3,n:v2})})})}return new Data_Either.Left("n m")}())(function(v1){return Control_Bind.bind(Data_Either.bindEither)(Control_Applicative.pure(Data_Either.applicativeEither)(Data_Array.mapMaybe(function(i){var v2=Data_String_Common.split(" ")(i);if(v2.length===2){return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_Int.fromString(v2[0]))(function(v3){return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_Int.fromString(v2[1]))(function(v4){return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(new Data_Tuple.Tuple(v3,v4))})})}return Data_Maybe.Nothing.value})(v.abss)))(function(v2){return Control_Bind.discard(Control_Bind.discardUnit)(Data_Either.bindEither)(function(){var $41=Data_Array.length(v2)===v1.n;if($41){return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Unit.unit)}return new Data_Either.Left("abs length")}())(function(){return Control_Applicative.pure(Data_Either.applicativeEither)(Data_Long_Unsigned.toString(solve$prime$prime(v1.m)(v2)))})})})})};var solve=function(input){var v=solve$prime(input);if(v instanceof Data_Either.Left){return Partial_Unsafe.unsafeCrashWith(v.value0)}if(v instanceof Data_Either.Right){return v.value0}throw new Error("Failed pattern match at AtCoder.ABC121.C (line 22, column 3 - line 24, column 17): "+[v.constructor.name])};exports["solve"]=solve})(PS["AtCoder.ABC121.C"]=PS["AtCoder.ABC121.C"]||{});(function(exports){"use strict";exports.log=function(s){return function(){console.log(s);return{}}}})(PS["Effect.Console"]=PS["Effect.Console"]||{});(function(exports){"use strict";var $foreign=PS["Effect.Console"];var Data_Show=PS["Data.Show"];var Data_Unit=PS["Data.Unit"];var Effect=PS["Effect"];exports["log"]=$foreign.log})(PS["Effect.Console"]=PS["Effect.Console"]||{});(function(exports){"use strict";var $foreign=PS["Node.Encoding"];var Data_Show=PS["Data.Show"];var Prelude=PS["Prelude"];var ASCII=function(){function ASCII(){}ASCII.value=new ASCII;return ASCII}();var UTF8=function(){function UTF8(){}UTF8.value=new UTF8;return UTF8}();var UTF16LE=function(){function UTF16LE(){}UTF16LE.value=new UTF16LE;return UTF16LE}();var UCS2=function(){function UCS2(){}UCS2.value=new UCS2;return UCS2}();var Base64=function(){function Base64(){}Base64.value=new Base64;return Base64}();var Latin1=function(){function Latin1(){}Latin1.value=new Latin1;return Latin1}();var Binary=function(){function Binary(){}Binary.value=new Binary;return Binary}();var Hex=function(){function Hex(){}Hex.value=new Hex;return Hex}();var showEncoding=new Data_Show.Show(function(v){if(v instanceof ASCII){return"ASCII"}if(v instanceof UTF8){return"UTF8"}if(v instanceof UTF16LE){return"UTF16LE"}if(v instanceof UCS2){return"UCS2"}if(v instanceof Base64){return"Base64"}if(v instanceof Latin1){return"Latin1"}if(v instanceof Binary){return"Binary"}if(v instanceof Hex){return"Hex"}throw new Error("Failed pattern match at Node.Encoding (line 19, column 1 - line 19, column 39): "+[v.constructor.name])});exports["ASCII"]=ASCII;exports["UTF8"]=UTF8;exports["UTF16LE"]=UTF16LE;exports["UCS2"]=UCS2;exports["Base64"]=Base64;exports["Latin1"]=Latin1;exports["Binary"]=Binary;exports["Hex"]=Hex;exports["showEncoding"]=showEncoding})(PS["Node.Encoding"]=PS["Node.Encoding"]||{});(function(exports){"use strict";exports.unsafeRequireFS=require("fs")})(PS["Node.FS.Internal"]=PS["Node.FS.Internal"]||{});(function(exports){"use strict";var $foreign=PS["Node.FS.Internal"];var Effect=PS["Effect"];var Prelude=PS["Prelude"];var Unsafe_Coerce=PS["Unsafe.Coerce"];var mkEffect=Unsafe_Coerce.unsafeCoerce;exports["mkEffect"]=mkEffect;exports["unsafeRequireFS"]=$foreign.unsafeRequireFS})(PS["Node.FS.Internal"]=PS["Node.FS.Internal"]||{});(function(exports){"use strict";var Control_Bind=PS["Control.Bind"];var Control_Semigroupoid=PS["Control.Semigroupoid"];var Data_DateTime=PS["Data.DateTime"];var Data_DateTime_Instant=PS["Data.DateTime.Instant"];var Data_EuclideanRing=PS["Data.EuclideanRing"];var Data_Function=PS["Data.Function"];var Data_Function_Uncurried=PS["Data.Function.Uncurried"];var Data_Functor=PS["Data.Functor"];var Data_Int=PS["Data.Int"];var Data_Maybe=PS["Data.Maybe"];var Data_Nullable=PS["Data.Nullable"];var Data_Show=PS["Data.Show"];var Data_Time_Duration=PS["Data.Time.Duration"];var Effect=PS["Effect"];var Node_Buffer=PS["Node.Buffer"];var Node_Encoding=PS["Node.Encoding"];var Node_FS=PS["Node.FS"];var Node_FS_Internal=PS["Node.FS.Internal"];var Node_FS_Perms=PS["Node.FS.Perms"];var Node_FS_Stats=PS["Node.FS.Stats"];var Node_Path=PS["Node.Path"];var Prelude=PS["Prelude"];var fs=Node_FS_Internal.unsafeRequireFS;var readTextFile=function(encoding){return function(file){return Node_FS_Internal.mkEffect(function(v){return fs.readFileSync(file,{encoding:Data_Show.show(Node_Encoding.showEncoding)(encoding)})})}};exports["readTextFile"]=readTextFile})(PS["Node.FS.Sync"]=PS["Node.FS.Sync"]||{});(function(exports){"use strict";var AtCoder_ABC121_C=PS["AtCoder.ABC121.C"];var Control_Applicative=PS["Control.Applicative"];var Control_Bind=PS["Control.Bind"];var Effect=PS["Effect"];var Effect_Console=PS["Effect.Console"];var Node_Encoding=PS["Node.Encoding"];var Node_FS_Sync=PS["Node.FS.Sync"];var Prelude=PS["Prelude"];var solve=AtCoder_ABC121_C.solve;var main=function __do(){var v=Node_FS_Sync.readTextFile(Node_Encoding.UTF8.value)("/dev/stdin")();var v1=solve(v);return Effect_Console.log(v1)()};exports["main"]=main})(PS["Main"]=PS["Main"]||{});PS["Main"].main();