module.exports=function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=0)}([function(t,r,n){"use strict";var e=n(1);n(2)(e.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,n){"use strict";var e=n(3),i=n(5);t.exports=function(t){var r=new e(t);i(r)}},function(t,r,n){"use strict";var e=n(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new e(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,n){"use strict";var e=n(6);t.exports=function(t){for(var r=t.in(),n=[],i=0;i<r;i++)for(var s=0;s<r;s++){var o=t.in();-1!=o&&n.push({s:i,t:s,c:o})}for(var u=e(r,n),a=u.length,c=0,f=0;f<a;f++)c+=u[f].c;console.log(c)}},function(t,r,n){"use strict";var e=n(7);t.exports=function(t,r){var n=new e(t),i=[],s=r.concat();s.sort(function(t,r){return t.c-r.c});for(var o=0;i.length<t-1;){var u=s[o++];n.isSameGroup(u.s,u.t)||(i.push(u),n.unite(u.s,u.t))}return i}},function(t,r,n){"use strict";t.exports=class{constructor(t){this.N=t,this.par=new Array(this.N),this.rank=new Array(this.N);for(var r=0;r<this.N;r++)this.par[r]=r,this.rank[r]=0}find(t){return this.par[t]==t?t:this.par[t]=this.find(this.par[t])}unite(t,r){var n=this.find(t),e=this.find(r);n!=e&&(this.rank[n]<this.rank[e]?this.par[n]=e:(this.par[e]=n,this.rank[n]==this.rank[e]&&this.rank[n]++))}isSameGroup(t,r){return this.find(t)==this.find(r)}}}]);
