import java.util.*

data class Component(val size: Int, val bipartite: Boolean)

// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

data class BFSState(val v: Int, val c: Int)

fun main(args: Array<String>) {
  val (n, m) = fastReadInts(2)
  val graph = Array(n, { mutableListOf<Int>() })
  repeat(m) {
    val (v1Raw, v2Raw) = fastReadInts(2)
    val v1 = v1Raw - 1
    val v2 = v2Raw - 1
    graph[v1].add(v2)
    graph[v2].add(v1)
  }

  val colors = IntArray(n, { -1 })
  val components = mutableListOf<Component>()
  var numIsolated = 0
  for (s in 0 until n) {
    if (colors[s] >= 0) continue
    if (graph[s].isEmpty()) {
      colors[s] = 0
      numIsolated += 1
      continue
    }

    var componentSize = 0
    var isBipartite = true

    // BFS
    val queue = ArrayDeque<BFSState>()
    componentSize += 1
    colors[s] = 0
    queue.offerLast(BFSState(s, 0))
    while (queue.isNotEmpty()) {
      val state = queue.pollFirst()
      val v = state.v
      val c = state.c
      val nextC = (c + 1) % 2

      // Bipartite check
      for (u in graph[v]) {
        if (colors[u] >= 0 && colors[u] == c) {
          isBipartite = false
        }
      }

      for (u in graph[v]) {
        if (colors[u] >= 0) continue
        componentSize += 1
        colors[u] = nextC
        queue.offerLast(BFSState(u, nextC))
      }
    }

    components.add(Component(componentSize, isBipartite))
  }

//  println("components: " + components)
//  println("numIsolated: " + numIsolated)

  var ans = 0L
  
  val numBipartite = components.count { it.bipartite }
  // val numNonBipartite = components.count { !it.bipartite }
  ans += components.size.toLong() * components.size.toLong() +
      numBipartite.toLong() * numBipartite.toLong()

  ans += 2L * n.toLong() * numIsolated.toLong() - numIsolated.toLong() * numIsolated.toLong()

  println(ans)
}
