output_description: Print the number of the connected components in the graph constructed by
  Takahashi.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N M
      u_1 v_1
      u_2 v_2
      :
      u_M v_M
attempt: N, M = map(int, input().split())
  
  
  class UF:
      def __init__(self):
          self.live = [True] * (N**2)
  
      def _connect(self, i, j):
          if self.live[i]:
              self.live[i] = False
          else:
              self.live[j] = False
  
      def connect(self, e1, e2):
          a1, a2 = e1
          b1, b2 = e2
          self._connect(a1 * N + b1, a2 * N + b2)
          self._connect(a1 * N + b2, a2 * N + b1)
  
      def count(self):
          return sum(self.live)
  
  
  uf = UF()
  
  edges = []
  for i in range(M):
      new_edge = list(map(int, input().split()))
      new_edge[0] -= 1
      new_edge[1] -= 1
      edges.append(new_edge)
      for edge in edges:
          uf.connect(new_edge, edge)
  
  print(uf.count())
  print(uf.live)
  
problem_description: Statement
  
  Takahashi has received an undirected graph with N vertices, numbered 1, 2,
  ..., N. The edges in this graph are represented by (u_i, v_i). There are no
  self-loops and multiple edges in this graph.
  
  Based on this graph, Takahashi is now constructing a new graph with N^2
  vertices, where each vertex is labeled with a pair of integers (a, b) (1 \leq
  a \leq N, 1 \leq b \leq N). The edges in this new graph are generated by the
  following rule:
  
    * Span an edge between vertices (a, b) and (a', b') if and only if both of the following two edges exist in the original graph: an edge between vertices a and a', and an edge between vertices b and b'.
  
  How many connected components are there in this new graph?
samples: [{"input": "3 1\n    1 2", "output": "7\n    \n\nThe graph constructed by Takahashi is as follows.\n\n![](https://atcoder.jp/img/agc011/6d34a4ddeba67b2286c00acda56abbcc.png)\n\n* * *"}, {"input": "7 5\n    1 2\n    3 4\n    3 5\n    4 5\n    2 6", "output": "18"}]