Enumerable=function(){var y="Single:sequence contains more than one element.",e=!0,r=null,i=!1,n=function(n){this.GetEnumerator=n},l,o;n.Choice=function(){var t=arguments[0]instanceof Array?arguments[0]:arguments;return new n(function(){return new u(f.Blank,function(){return this.Yield(t[Math.floor(Math.random()*t.length)])},f.Blank)})};n.Cycle=function(){var t=arguments[0]instanceof Array?arguments[0]:arguments;return new n(function(){var n=0;return new u(f.Blank,function(){return n>=t.length&&(n=0),this.Yield(t[n++])},f.Blank)})};n.Empty=function(){return new n(function(){return new u(f.Blank,function(){return i},f.Blank)})};n.From=function(h){if(h==r)return n.Empty();if(h instanceof n)return h;if(typeof h==s.Number||typeof h==s.Boolean)return n.Repeat(h,1);if(typeof h==s.String)return new n(function(){var n=0;return new u(f.Blank,function(){return n<h.length?this.Yield(h.charAt(n++)):i},f.Blank)});if(typeof h!=s.Function){if(typeof h.length==s.Number)return new o(h);if(!(h instanceof Object)&&t.IsIEnumerable(h))return new n(function(){var t=e,n;return new u(function(){n=new Enumerator(h)},function(){return t?t=i:n.moveNext(),n.atEnd()?i:this.Yield(n.item())},f.Blank)})}return new n(function(){var n=[],t=0;return new u(function(){for(var t in h)h[t]instanceof Function||n.push({Key:t,Value:h[t]})},function(){return t<n.length?this.Yield(n[t++]):i},f.Blank)})};n.Return=function(t){return n.Repeat(t,1)};n.Matches=function(t,e,o){return o==r&&(o=""),e instanceof RegExp&&(o+=e.ignoreCase?"i":"",o+=e.multiline?"m":"",e=e.source),o.indexOf("g")===-1&&(o+="g"),new n(function(){var n;return new u(function(){n=new RegExp(e,o)},function(){var r=n.exec(t);return r?this.Yield(r):i},f.Blank)})};n.Range=function(t,i,u){return u==r&&(u=1),n.ToInfinity(t,u).Take(i)};n.RangeDown=function(t,i,u){return u==r&&(u=1),n.ToNegativeInfinity(t,u).Take(i)};n.RangeTo=function(t,i,u){return u==r&&(u=1),t<i?n.ToInfinity(t,u).TakeWhile(function(n){return n<=i}):n.ToNegativeInfinity(t,u).TakeWhile(function(n){return n>=i})};n.Repeat=function(t,i){return i!=r?n.Repeat(t).Take(i):new n(function(){return new u(f.Blank,function(){return this.Yield(t)},f.Blank)})};n.RepeatWithFinalize=function(i,f){return i=t.CreateLambda(i),f=t.CreateLambda(f),new n(function(){var n;return new u(function(){n=i()},function(){return this.Yield(n)},function(){n!=r&&(f(n),n=r)})})};n.Generate=function(i,e){return e!=r?n.Generate(i).Take(e):(i=t.CreateLambda(i),new n(function(){return new u(f.Blank,function(){return this.Yield(i())},f.Blank)}))};n.ToInfinity=function(t,i){return t==r&&(t=0),i==r&&(i=1),new n(function(){var n;return new u(function(){n=t-i},function(){return this.Yield(n+=i)},f.Blank)})};n.ToNegativeInfinity=function(t,i){return t==r&&(t=0),i==r&&(i=1),new n(function(){var n;return new u(function(){n=t+i},function(){return this.Yield(n-=i)},f.Blank)})};n.Unfold=function(r,o){return o=t.CreateLambda(o),new n(function(){var t=e,n;return new u(f.Blank,function(){return t?(t=i,n=r,this.Yield(n)):(n=o(n),this.Yield(n))},f.Blank)})};n.prototype={CascadeBreadthFirst:function(r,f){var o=this;return r=t.CreateLambda(r),f=t.CreateLambda(f),new n(function(){var s,c=0,h=[];return new u(function(){s=o.GetEnumerator()},function(){while(e){if(s.MoveNext())return h.push(s.Current()),this.Yield(f(s.Current(),c));var u=n.From(h).SelectMany(function(n){return r(n)});if(u.Any())c++,h=[],t.Dispose(s),s=u.GetEnumerator();else return i}},function(){t.Dispose(s)})})},CascadeDepthFirst:function(r,f){var o=this;return r=t.CreateLambda(r),f=t.CreateLambda(f),new n(function(){var h=[],s;return new u(function(){s=o.GetEnumerator()},function(){while(e){if(s.MoveNext()){var u=f(s.Current(),h.length);return h.push(s),s=n.From(r(s.Current())).GetEnumerator(),this.Yield(u)}if(h.length<=0)return i;t.Dispose(s);s=h.pop()}},function(){try{t.Dispose(s)}finally{n.From(h).ForEach(function(n){n.Dispose()})}})})},Flatten:function(){var o=this;return new n(function(){var h,s=r;return new u(function(){h=o.GetEnumerator()},function(){while(e){if(s!=r){if(s.MoveNext())return this.Yield(s.Current());s=r}if(h.MoveNext())if(h.Current()instanceof Array){t.Dispose(s);s=n.From(h.Current()).SelectMany(f.Identity).Flatten().GetEnumerator();continue}else return this.Yield(h.Current());return i}},function(){try{t.Dispose(h)}finally{t.Dispose(s)}})})},Pairwise:function(r){var f=this;return r=t.CreateLambda(r),new n(function(){var n;return new u(function(){n=f.GetEnumerator();n.MoveNext()},function(){var t=n.Current();return n.MoveNext()?this.Yield(r(t,n.Current())):i},function(){t.Dispose(n)})})},Scan:function(f,o,s){var h,c;return s!=r?this.Scan(f,o).Select(s):(o==r?(o=t.CreateLambda(f),h=i):(o=t.CreateLambda(o),h=e),c=this,new n(function(){var n,r,s=e;return new u(function(){n=c.GetEnumerator()},function(){if(s){if(s=i,h)return this.Yield(r=f);if(n.MoveNext())return this.Yield(r=n.Current())}return n.MoveNext()?this.Yield(r=o(r,n.Current())):i},function(){t.Dispose(n)})}))},Select:function(r){var f=this;return r=t.CreateLambda(r),new n(function(){var n,e=0;return new u(function(){n=f.GetEnumerator()},function(){return n.MoveNext()?this.Yield(r(n.Current(),e++)):i},function(){t.Dispose(n)})})},SelectMany:function(f,e){var o=this;return f=t.CreateLambda(f),e==r&&(e=function(n,t){return t}),e=t.CreateLambda(e),new n(function(){var h,s=undefined,c=0;return new u(function(){h=o.GetEnumerator()},function(){if(s===undefined&&!h.MoveNext())return i;do{if(s==r){var u=f(h.Current(),c++);s=n.From(u).GetEnumerator()}if(s.MoveNext())return this.Yield(e(h.Current(),s.Current()));t.Dispose(s);s=r}while(h.MoveNext());return i},function(){try{t.Dispose(h)}finally{t.Dispose(s)}})})},Where:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var n,e=0;return new u(function(){n=f.GetEnumerator()},function(){while(n.MoveNext())if(r(n.Current(),e++))return this.Yield(n.Current());return i},function(){t.Dispose(n)})})},OfType:function(n){var t;switch(n){case Number:t=s.Number;break;case String:t=s.String;break;case Boolean:t=s.Boolean;break;case Function:t=s.Function;break;default:t=r}return t===r?this.Where(function(t){return t instanceof n}):this.Where(function(n){return typeof n===t})},Zip:function(r,f){f=t.CreateLambda(f);var e=this;return new n(function(){var o,s,h=0;return new u(function(){o=e.GetEnumerator();s=n.From(r).GetEnumerator()},function(){return o.MoveNext()&&s.MoveNext()?this.Yield(f(o.Current(),s.Current(),h++)):i},function(){try{t.Dispose(o)}finally{t.Dispose(s)}})})},Join:function(o,s,h,c,l){s=t.CreateLambda(s);h=t.CreateLambda(h);c=t.CreateLambda(c);l=t.CreateLambda(l);var a=this;return new n(function(){var v,p,y=r,w=0;return new u(function(){v=a.GetEnumerator();p=n.From(o).ToLookup(h,f.Identity,l)},function(){for(var n,t;e;){if(y!=r){if(n=y[w++],n!==undefined)return this.Yield(c(v.Current(),n));n=r;w=0}if(v.MoveNext())t=s(v.Current()),y=p.Get(t).ToArray();else return i}},function(){t.Dispose(v)})})},GroupJoin:function(e,o,s,h,c){o=t.CreateLambda(o);s=t.CreateLambda(s);h=t.CreateLambda(h);c=t.CreateLambda(c);var l=this;return new n(function(){var a=l.GetEnumerator(),v=r;return new u(function(){a=l.GetEnumerator();v=n.From(e).ToLookup(s,f.Identity,c)},function(){if(a.MoveNext()){var n=v.Get(o(a.Current()));return this.Yield(h(a.Current(),n))}return i},function(){t.Dispose(a)})})},All:function(n){n=t.CreateLambda(n);var r=e;return this.ForEach(function(t){if(!n(t))return r=i,i}),r},Any:function(n){n=t.CreateLambda(n);var r=this.GetEnumerator();try{if(arguments.length==0)return r.MoveNext();while(r.MoveNext())if(n(r.Current()))return e;return i}finally{t.Dispose(r)}},Concat:function(f){var e=this;return new n(function(){var s,o;return new u(function(){s=e.GetEnumerator()},function(){if(o==r){if(s.MoveNext())return this.Yield(s.Current());o=n.From(f).GetEnumerator()}return o.MoveNext()?this.Yield(o.Current()):i},function(){try{t.Dispose(s)}finally{t.Dispose(o)}})})},Insert:function(r,f){var o=this;return new n(function(){var h,s,c=0,l=i;return new u(function(){h=o.GetEnumerator();s=n.From(f).GetEnumerator()},function(){return c==r&&s.MoveNext()?(l=e,this.Yield(s.Current())):h.MoveNext()?(c++,this.Yield(h.Current())):!l&&s.MoveNext()?this.Yield(s.Current()):i},function(){try{t.Dispose(h)}finally{t.Dispose(s)}})})},Alternate:function(t){return t=n.Return(t),this.SelectMany(function(i){return n.Return(i).Concat(t)}).TakeExceptLast()},Contains:function(n,r){r=t.CreateLambda(r);var u=this.GetEnumerator();try{while(u.MoveNext())if(r(u.Current())===n)return e;return i}finally{t.Dispose(u)}},DefaultIfEmpty:function(r){var f=this;return new n(function(){var n,o=e;return new u(function(){n=f.GetEnumerator()},function(){return n.MoveNext()?(o=i,this.Yield(n.Current())):o?(o=i,this.Yield(r)):i},function(){t.Dispose(n)})})},Distinct:function(t){return this.Except(n.Empty(),t)},Except:function(r,f){f=t.CreateLambda(f);var e=this;return new n(function(){var o,s;return new u(function(){o=e.GetEnumerator();s=new a(f);n.From(r).ForEach(function(n){s.Add(n)})},function(){while(o.MoveNext()){var n=o.Current();if(!s.Contains(n))return s.Add(n),this.Yield(n)}return i},function(){t.Dispose(o)})})},Intersect:function(r,f){f=t.CreateLambda(f);var e=this;return new n(function(){var o,s,h;return new u(function(){o=e.GetEnumerator();s=new a(f);n.From(r).ForEach(function(n){s.Add(n)});h=new a(f)},function(){while(o.MoveNext()){var n=o.Current();if(!h.Contains(n)&&s.Contains(n))return h.Add(n),this.Yield(n)}return i},function(){t.Dispose(o)})})},SequenceEqual:function(r,u){var o,f;u=t.CreateLambda(u);o=this.GetEnumerator();try{f=n.From(r).GetEnumerator();try{while(o.MoveNext())if(!f.MoveNext()||u(o.Current())!==u(f.Current()))return i;return f.MoveNext()?i:e}finally{t.Dispose(f)}}finally{t.Dispose(o)}},Union:function(r,f){f=t.CreateLambda(f);var e=this;return new n(function(){var h,o,s;return new u(function(){h=e.GetEnumerator();s=new a(f)},function(){var t;if(o===undefined){while(h.MoveNext())if(t=h.Current(),!s.Contains(t))return s.Add(t),this.Yield(t);o=n.From(r).GetEnumerator()}while(o.MoveNext())if(t=o.Current(),!s.Contains(t))return s.Add(t),this.Yield(t);return i},function(){try{t.Dispose(h)}finally{t.Dispose(o)}})})},OrderBy:function(n){return new h(this,n,i)},OrderByDescending:function(n){return new h(this,n,e)},Reverse:function(){var t=this;return new n(function(){var n,r;return new u(function(){n=t.ToArray();r=n.length},function(){return r>0?this.Yield(n[--r]):i},f.Blank)})},Shuffle:function(){var t=this;return new n(function(){var n;return new u(function(){n=t.ToArray()},function(){if(n.length>0){var t=Math.floor(Math.random()*n.length);return this.Yield(n.splice(t,1)[0])}return i},f.Blank)})},GroupBy:function(f,e,o,s){var h=this;return f=t.CreateLambda(f),e=t.CreateLambda(e),o!=r&&(o=t.CreateLambda(o)),s=t.CreateLambda(s),new n(function(){var n;return new u(function(){n=h.ToLookup(f,e,s).ToEnumerable().GetEnumerator()},function(){while(n.MoveNext())return o==r?this.Yield(n.Current()):this.Yield(o(n.Current().Key(),n.Current()));return i},function(){t.Dispose(n)})})},PartitionBy:function(f,o,s,h){var l=this,c;return f=t.CreateLambda(f),o=t.CreateLambda(o),h=t.CreateLambda(h),s==r?(c=i,s=function(n,t){return new v(n,t)}):(c=e,s=t.CreateLambda(s)),new n(function(){var r,v,y,a=[];return new u(function(){r=l.GetEnumerator();r.MoveNext()&&(v=f(r.Current()),y=h(v),a.push(o(r.Current())))},function(){for(var t,u;(t=r.MoveNext())==e;)if(y===h(f(r.Current())))a.push(o(r.Current()));else break;return a.length>0?(u=c?s(v,n.From(a)):s(v,a),t?(v=f(r.Current()),y=h(v),a=[o(r.Current())]):a=[],this.Yield(u)):i},function(){t.Dispose(r)})})},BufferWithCount:function(r){var f=this;return new n(function(){var n;return new u(function(){n=f.GetEnumerator()},function(){for(var t=[],u=0;n.MoveNext();)if(t.push(n.Current()),++u>=r)return this.Yield(t);return t.length>0?this.Yield(t):i},function(){t.Dispose(n)})})},Aggregate:function(n,t,i){return this.Scan(n,t,i).Last()},Average:function(n){n=t.CreateLambda(n);var i=0,r=0;return this.ForEach(function(t){i+=n(t);++r}),i/r},Count:function(n){n=n==r?f.True:t.CreateLambda(n);var i=0;return this.ForEach(function(t,r){n(t,r)&&++i}),i},Max:function(n){return n==r&&(n=f.Identity),this.Select(n).Aggregate(function(n,t){return n>t?n:t})},Min:function(n){return n==r&&(n=f.Identity),this.Select(n).Aggregate(function(n,t){return n<t?n:t})},MaxBy:function(n){return n=t.CreateLambda(n),this.Aggregate(function(t,i){return n(t)>n(i)?t:i})},MinBy:function(n){return n=t.CreateLambda(n),this.Aggregate(function(t,i){return n(t)<n(i)?t:i})},Sum:function(n){return n==r&&(n=f.Identity),this.Select(n).Aggregate(0,function(n,t){return n+t})},ElementAt:function(n){var t,r=i;if(this.ForEach(function(u,f){if(f==n)return t=u,r=e,i}),!r)throw new Error("index is less than 0 or greater than or equal to the number of elements in source.");return t},ElementAtOrDefault:function(n,t){var r,u=i;return this.ForEach(function(t,f){if(f==n)return r=t,u=e,i}),u?r:t},First:function(n){if(n!=r)return this.Where(n).First();var t,u=i;if(this.ForEach(function(n){return t=n,u=e,i}),!u)throw new Error("First:No element satisfies the condition.");return t},FirstOrDefault:function(n,t){if(t!=r)return this.Where(t).FirstOrDefault(n);var u,f=i;return this.ForEach(function(n){return u=n,f=e,i}),f?u:n},Last:function(n){if(n!=r)return this.Where(n).Last();var t,u=i;if(this.ForEach(function(n){u=e;t=n}),!u)throw new Error("Last:No element satisfies the condition.");return t},LastOrDefault:function(n,t){if(t!=r)return this.Where(t).LastOrDefault(n);var u,f=i;return this.ForEach(function(n){f=e;u=n}),f?u:n},Single:function(n){if(n!=r)return this.Where(n).Single();var u,t=i;if(this.ForEach(function(n){if(t)throw new Error(y);else t=e,u=n}),!t)throw new Error("Single:No element satisfies the condition.");return u},SingleOrDefault:function(n,t){if(t!=r)return this.Where(t).SingleOrDefault(n);var f,u=i;return this.ForEach(function(n){if(u)throw new Error(y);else u=e,f=n}),u?f:n},Skip:function(r){var f=this;return new n(function(){var n,e=0;return new u(function(){for(n=f.GetEnumerator();e++<r&&n.MoveNext(););},function(){return n.MoveNext()?this.Yield(n.Current()):i},function(){t.Dispose(n)})})},SkipWhile:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var n,s=0,o=i;return new u(function(){n=f.GetEnumerator()},function(){while(!o)if(n.MoveNext()){if(!r(n.Current(),s++))return o=e,this.Yield(n.Current());continue}else return i;return n.MoveNext()?this.Yield(n.Current()):i},function(){t.Dispose(n)})})},Take:function(r){var f=this;return new n(function(){var n,e=0;return new u(function(){n=f.GetEnumerator()},function(){return e++<r&&n.MoveNext()?this.Yield(n.Current()):i},function(){t.Dispose(n)})})},TakeWhile:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var n,e=0;return new u(function(){n=f.GetEnumerator()},function(){return n.MoveNext()&&r(n.Current(),e++)?this.Yield(n.Current()):i},function(){t.Dispose(n)})})},TakeExceptLast:function(f){f==r&&(f=1);var e=this;return new n(function(){if(f<=0)return e.GetEnumerator();var n,r=[];return new u(function(){n=e.GetEnumerator()},function(){while(n.MoveNext()){if(r.length==f)return r.push(n.Current()),this.Yield(r.shift());r.push(n.Current())}return i},function(){t.Dispose(n)})})},TakeFromLast:function(f){if(f<=0||f==r)return n.Empty();var e=this;return new n(function(){var h,o,s=[];return new u(function(){h=e.GetEnumerator()},function(){while(h.MoveNext())s.length==f&&s.shift(),s.push(h.Current());return o==r&&(o=n.From(s).GetEnumerator()),o.MoveNext()?this.Yield(o.Current()):i},function(){t.Dispose(o)})})},IndexOf:function(n){var t=r;return this.ForEach(function(i,r){if(i===n)return t=r,e}),t!==r?t:-1},LastIndexOf:function(n){var t=-1;return this.ForEach(function(i,r){i===n&&(t=r)}),t},ToArray:function(){var n=[];return this.ForEach(function(t){n.push(t)}),n},ToLookup:function(n,i,r){n=t.CreateLambda(n);i=t.CreateLambda(i);r=t.CreateLambda(r);var u=new a(r);return this.ForEach(function(t){var r=n(t),f=i(t),e=u.Get(r);e!==undefined?e.push(f):u.Add(r,[f])}),new w(u)},ToObject:function(n,i){n=t.CreateLambda(n);i=t.CreateLambda(i);var r={};return this.ForEach(function(t){r[n(t)]=i(t)}),r},ToDictionary:function(n,i,r){n=t.CreateLambda(n);i=t.CreateLambda(i);r=t.CreateLambda(r);var u=new a(r);return this.ForEach(function(t){u.Add(n(t),i(t))}),u},ToJSON:function(n,t){return JSON.stringify(this.ToArray(),n,t)},ToString:function(n,t){return n==r&&(n=""),t==r&&(t=f.Identity),this.Select(t).ToArray().join(n)},Do:function(r){var f=this;return r=t.CreateLambda(r),new n(function(){var n,e=0;return new u(function(){n=f.GetEnumerator()},function(){return n.MoveNext()?(r(n.Current(),e++),this.Yield(n.Current())):i},function(){t.Dispose(n)})})},ForEach:function(n){n=t.CreateLambda(n);var u=0,r=this.GetEnumerator();try{while(r.MoveNext())if(n(r.Current(),u++)===i)break}finally{t.Dispose(r)}},Write:function(n,u){n==r&&(n="");u=t.CreateLambda(u);var f=e;this.ForEach(function(t){f?f=i:document.write(n);document.write(u(t))})},WriteLine:function(n){n=t.CreateLambda(n);this.ForEach(function(t){document.write(n(t));document.write("<br />")})},Force:function(){var n=this.GetEnumerator();try{while(n.MoveNext());}finally{t.Dispose(n)}},Let:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var e;return new u(function(){e=n.From(r(f)).GetEnumerator()},function(){return e.MoveNext()?this.Yield(e.Current()):i},function(){t.Dispose(e)})})},Share:function(){var e=this,t;return new n(function(){return new u(function(){t==r&&(t=e.GetEnumerator())},function(){return t.MoveNext()?this.Yield(t.Current()):i},f.Blank)})},MemoizeAll:function(){var o=this,t,e;return new n(function(){var n=-1;return new u(function(){e==r&&(e=o.GetEnumerator(),t=[])},function(){return n++,t.length<=n?e.MoveNext()?this.Yield(t[n]=e.Current()):i:this.Yield(t[n])},f.Blank)})},Catch:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var n;return new u(function(){n=f.GetEnumerator()},function(){try{return n.MoveNext()?this.Yield(n.Current()):i}catch(t){return r(t),i}},function(){t.Dispose(n)})})},Finally:function(r){r=t.CreateLambda(r);var f=this;return new n(function(){var n;return new u(function(){n=f.GetEnumerator()},function(){return n.MoveNext()?this.Yield(n.Current()):i},function(){try{t.Dispose(n)}finally{r()}})})},Trace:function(n,i){return n==r&&(n="Trace"),i=t.CreateLambda(i),this.Do(function(t){console.log(n,":",i(t))})}};var f={Identity:function(n){return n},True:function(){return e},Blank:function(){}},s={Boolean:typeof e,Number:"number",String:"string",Object:"object",Undefined:typeof undefined,Function:typeof function(){}},t={CreateLambda:function(n){if(n==r)return f.Identity;if(typeof n==s.String){if(n=="")return f.Identity;if(n.indexOf("=>")==-1)return new Function("$,$$,$$$,$$$$","return "+n);var t=n.match(/^[(\s]*([^()]*?)[)\s]*=>(.*)/);return new Function(t[1],"return "+t[2])}return n},IsIEnumerable:function(n){if(typeof Enumerator!=s.Undefined)try{return new Enumerator(n),e}catch(t){}return i},Compare:function(n,t){return n===t?0:n>t?1:-1},Dispose:function(n){n!=r&&n.Dispose()}},c={Before:0,Running:1,After:2},u=function(n,t,r){var f=new p,u=c.Before;this.Current=f.Current;this.MoveNext=function(){try{switch(u){case c.Before:u=c.Running;n();case c.Running:return t.apply(f)?e:(this.Dispose(),i);case c.After:return i}}catch(r){this.Dispose();throw r;}};this.Dispose=function(){if(u==c.Running)try{r()}finally{u=c.After}}},p=function(){var n=r;this.Current=function(){return n};this.Yield=function(t){return n=t,e}},h=function(n,i,r,u){var f=this;f.source=n;f.keySelector=t.CreateLambda(i);f.descending=r;f.parent=u};h.prototype=new n;h.prototype.CreateOrderedEnumerable=function(n,t){return new h(this.source,n,t,this)};h.prototype.ThenBy=function(n){return this.CreateOrderedEnumerable(n,i)};h.prototype.ThenByDescending=function(n){return this.CreateOrderedEnumerable(n,e)};h.prototype.GetEnumerator=function(){var e=this,t,n,o=0;return new u(function(){t=[];n=[];e.source.ForEach(function(i,r){t.push(i);n.push(r)});var i=l.Create(e,r);i.GenerateKeys(t);n.sort(function(n,t){return i.Compare(n,t)})},function(){return o<n.length?this.Yield(t[n[o++]]):i},f.Blank)};l=function(n,t,i){var u=this;u.keySelector=n;u.descending=t;u.child=i;u.keys=r};l.Create=function(n,t){var i=new l(n.keySelector,n.descending,t);return n.parent!=r?l.Create(n.parent,i):i};l.prototype.GenerateKeys=function(n){for(var t=this,u=n.length,e=t.keySelector,f=new Array(u),i=0;i<u;i++)f[i]=e(n[i]);t.keys=f;t.child!=r&&t.child.GenerateKeys(n)};l.prototype.Compare=function(n,i){var u=this,f=t.Compare(u.keys[n],u.keys[i]);if(f==0){if(u.child!=r)return u.child.Compare(n,i);f=t.Compare(n,i)}return u.descending?-f:f};o=function(n){this.source=n};o.prototype=new n;o.prototype.Any=function(t){return t==r?this.source.length>0:n.prototype.Any.apply(this,arguments)};o.prototype.Count=function(t){return t==r?this.source.length:n.prototype.Count.apply(this,arguments)};o.prototype.ElementAt=function(t){return 0<=t&&t<this.source.length?this.source[t]:n.prototype.ElementAt.apply(this,arguments)};o.prototype.ElementAtOrDefault=function(n,t){return 0<=n&&n<this.source.length?this.source[n]:t};o.prototype.First=function(t){return t==r&&this.source.length>0?this.source[0]:n.prototype.First.apply(this,arguments)};o.prototype.FirstOrDefault=function(t,i){return i!=r?n.prototype.FirstOrDefault.apply(this,arguments):this.source.length>0?this.source[0]:t};o.prototype.Last=function(t){var i=this;return t==r&&i.source.length>0?i.source[i.source.length-1]:n.prototype.Last.apply(i,arguments)};o.prototype.LastOrDefault=function(t,i){var u=this;return i!=r?n.prototype.LastOrDefault.apply(u,arguments):u.source.length>0?u.source[u.source.length-1]:t};o.prototype.Skip=function(t){var r=this.source;return new n(function(){var n;return new u(function(){n=t<0?0:t},function(){return n<r.length?this.Yield(r[n++]):i},f.Blank)})};o.prototype.TakeExceptLast=function(n){return n==r&&(n=1),this.Take(this.source.length-n)};o.prototype.TakeFromLast=function(n){return this.Skip(this.source.length-n)};o.prototype.Reverse=function(){var t=this.source;return new n(function(){var n;return new u(function(){n=t.length},function(){return n>0?this.Yield(t[--n]):i},f.Blank)})};o.prototype.SequenceEqual=function(t,u){return(t instanceof o||t instanceof Array)&&u==r&&n.From(t).Count()!=this.Count()?i:n.prototype.SequenceEqual.apply(this,arguments)};o.prototype.ToString=function(t,i){return i!=r||!(this.source instanceof Array)?n.prototype.ToString.apply(this,arguments):(t==r&&(t=""),this.source.join(t))};o.prototype.GetEnumerator=function(){var n=this.source,t=0;return new u(f.Blank,function(){return t<n.length?this.Yield(n[t++]):i},f.Blank)};var a=function(){var t=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},o=function(n){return n===r?"null":n===undefined?"undefined":typeof n.toString===s.Function?n.toString():Object.prototype.toString.call(n)},l=function(n,t){var i=this;i.Key=n;i.Value=t;i.Prev=r;i.Next=r},h=function(){this.First=r;this.Last=r},c;return h.prototype={AddLast:function(n){var t=this;t.Last!=r?(t.Last.Next=n,n.Prev=t.Last,t.Last=n):t.First=t.Last=n},Replace:function(n,t){n.Prev!=r?(n.Prev.Next=t,t.Prev=n.Prev):this.First=t;n.Next!=r?(n.Next.Prev=t,t.Next=n.Next):this.Last=t},Remove:function(n){n.Prev!=r?n.Prev.Next=n.Next:this.First=n.Next;n.Next!=r?n.Next.Prev=n.Prev:this.Last=n.Prev}},c=function(n){var t=this;t.count=0;t.entryList=new h;t.buckets={};t.compareSelector=n==r?f.Identity:n},c.prototype={Add:function(n,i){var r=this,h=r.compareSelector(n),s=o(h),e=new l(n,i),u,f;if(t(r.buckets,s)){for(u=r.buckets[s],f=0;f<u.length;f++)if(r.compareSelector(u[f].Key)===h){r.entryList.Replace(u[f],e);u[f]=e;return}u.push(e)}else r.buckets[s]=[e];r.count++;r.entryList.AddLast(e)},Get:function(n){var i=this,e=i.compareSelector(n),s=o(e),u,r,f;if(!t(i.buckets,s))return undefined;for(u=i.buckets[s],r=0;r<u.length;r++)if(f=u[r],i.compareSelector(f.Key)===e)return f.Value;return undefined},Set:function(n,r){var f=this,c=f.compareSelector(n),a=o(c),s,u,h;if(t(f.buckets,a))for(s=f.buckets[a],u=0;u<s.length;u++)if(f.compareSelector(s[u].Key)===c)return h=new l(n,r),f.entryList.Replace(s[u],h),s[u]=h,e;return i},Contains:function(n){var r=this,s=r.compareSelector(n),h=o(s),f,u;if(!t(r.buckets,h))return i;for(f=r.buckets[h],u=0;u<f.length;u++)if(r.compareSelector(f[u].Key)===s)return e;return i},Clear:function(){this.count=0;this.buckets={};this.entryList=new h},Remove:function(n){var i=this,e=i.compareSelector(n),f=o(e),r,u;if(t(i.buckets,f))for(r=i.buckets[f],u=0;u<r.length;u++)if(i.compareSelector(r[u].Key)===e){i.entryList.Remove(r[u]);r.splice(u,1);r.length==0&&delete i.buckets[f];i.count--;return}},Count:function(){return this.count},ToEnumerable:function(){var t=this;return new n(function(){var n;return new u(function(){n=t.entryList.First},function(){if(n!=r){var t={Key:n.Key,Value:n.Value};return n=n.Next,this.Yield(t)}return i},f.Blank)})}},c}(),w=function(t){var i=this;i.Count=function(){return t.Count()};i.Get=function(i){return n.From(t.Get(i))};i.Contains=function(n){return t.Contains(n)};i.ToEnumerable=function(){return t.ToEnumerable().Select(function(n){return new v(n.Key,n.Value)})}},v=function(n,t){this.Key=function(){return n};o.call(this,t)};return v.prototype=new o,n}()