output_description: Print the total weight of the minimum spanning tree of $G$.
input_description: In the first line, an integer $n$ denoting the number of vertices in $G$ is
  given. In the following $n$ lines, a $n \times n$ adjacency matrix $A$ which
  represents $G$ is given. $a_{ij}$ denotes the weight of edge connecting vertex
  $i$ and vertex $j$. If there is no edge between $i$ and $j$, $a_{ij}$ is given
  by -1.
attempt: n = int(input())
  a = []
  
  for i in range(n):
      inp = input()
      if "-1" in inp:
          inp = inp.replace("-1", "10000")
      a.append(list(map(int, inp.split())))
  
  w = 0
  v = set()
  v.add(0)
  
  while len(v) < n:
      print(v)
      min_w = 10000
      min_idx = 0
      i = 0
      for node in v:
          if min_w > min(a[node]):
              min_w = min(a[node])
              i = node
              min_idx = a[i].index(min_w)
      if min_idx in v:
          a[i][min_idx] = 10000
          continue
      else:
          w += min_w
          v.add(min_idx)
  
  print(w)
  
problem_description: Minimum Spanning Tree
  
  For a given weighted graph $G = (V, E)$, find the minimum spanning tree (MST)
  of $G$ and print total weight of edges belong to the MST.
samples: [{"input": "5\n     -1 2 3 1 -1\n     2 -1 -1 4 -1\n     3 -1 -1 1 1\n     1 4 1 -1 3\n     -1 -1 1 3 -1", "output": "5"}]