import sys

input = sys.stdin.readline



N,M = list(map(int,input().split()))

UV = [[int(x) for x in row.split()] for row in sys.stdin.readlines()]



graph = [[] for _ in range(N+1)]

for u,v in UV:

    graph[u].append(v)

    graph[v].append(u)



color = [None] * (N+1)



def calc_comp_data(v):

    c = 0

    q = [v]

    color[v] = 0

    is_bipartite = True

    size = 1

    while q:

        qq = []

        c ^= 1

        for x in q:

            for y in graph[x]:

                if color[y] is None:

                    color[y] = c

                    qq.append(y)

                    size += 1

                elif color[y] == c:

                    continue

                else:

                    is_bipartite = False

        q = qq

    return size,is_bipartite



size = []

is_bipartite = []

for v in range(1,N+1):

    if color[v] is not None:

        continue

    x,y = calc_comp_data(v)

    size.append(x)

    is_bipartite.append(y)



size,is_bipartite



n_point = sum(1 if s == 1 else 0 for s in size)

n_component = len(size)

n_bipartitle = sum(1 if s >= 2 and bl else 0 for s,bl in zip(size,is_bipartite))



answer = 0

for s,bl in zip(size,is_bipartite):

    if s == 1:

        # 第1成分が1点のとき

        answer += N

    elif not bl:

        # 第1成分が2点以上、非二部グラフ

        # 成分の個数が足される

        answer += (n_component - n_point) + s*n_point

    else:

        # 第1成分が2点以上の二部グラフ

        # 相手が2点以上の二部グラフなら、2つできる

        answer += (n_component - n_point) + n_bipartitle + s*n_point



print(answer)
import sys



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, M = list(map(int, readline().split()))

m = list(map(int, read().split()))

G = [[] for _ in range(N + 1)]

for a, b in zip(m, m):

    G[a].append(b)

    G[b].append(a)



comp = [0] * (N + 1)

comp_size = [0] * (N + 1)

is_bipartite = [1] * (N + 1)

color = [0] * (N + 1)



for r in range(1, N + 1):

    if comp[r]:

        continue

    comp[r] = r

    comp_size[r] = 1

    stack = [r]

    while stack:

        v = stack.pop()

        for w in G[v]:

            if comp[w]:

                if color[v] == color[w]:

                    is_bipartite[r] = 0

                continue

            comp[w] = r

            comp_size[r] += 1

            color[w] = 1 ^ color[v]

            stack.append(w)



a, b, c = 0, 0, 0  # point,odd,even

for r in range(1, N + 1):

    if r != comp[r]:

        continue

    if comp_size[r] == 1:

        a += 1

    elif is_bipartite[r]:

        c += 1

    else:

        b += 1



x = 2 * a * N - a * a + b * b + 2 * b * c + 2 * c * c

print(x)
import sys

input = sys.stdin.readline
N, M = list(map(int, input().split()))
UV = [[int(x) for x in row.split()] for row in sys.stdin.readlines()]
graph = [[] for _ in range(N + 1)]
for u, v in UV:
    graph[u].append(v)
    graph[v].append(u)
color = [None] * (N + 1)


def calc_comp_data(v):
    c = 0
    q = [v]
    color[v] = 0
    is_bipartite = True
    size = 1
    while q:
        qq = []
        c ^= 1
        for x in q:
            for y in graph[x]:
                if color[y] is None:
                    color[y] = c
                    qq.append(y)
                    size += 1
                elif color[y] == c:
                    continue
                else:
                    is_bipartite = False
        q = qq
    return size, is_bipartite


size = []
is_bipartite = []
for v in range(1, N + 1):
    if color[v] is not None:
        continue
    x, y = calc_comp_data(v)
    size.append(x)
    is_bipartite.append(y)
size, is_bipartite
n_point = sum(1 if s == 1 else 0 for s in size)
n_component = len(size)
n_bipartitle = sum(1 if s >= 2 and bl else 0 for s, bl in zip(size, is_bipartite))
answer = 0
for s, bl in zip(size, is_bipartite):
    if s == 1:
        # 第1成分が1点のとき
        answer += N
    elif not bl:
        # 第1成分が2点以上、非二部グラフ
        # 成分の個数が足される
        answer += (n_component - n_point) + s * n_point
    else:
        # 第1成分が2点以上の二部グラフ
        # 相手が2点以上の二部グラフなら、2つできる
        answer += (n_component - n_point) + n_bipartitle + s * n_point
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
G = [[] for _ in range(N + 1)]
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)
comp = [0] * (N + 1)
comp_size = [0] * (N + 1)
is_bipartite = [1] * (N + 1)
color = [0] * (N + 1)
for r in range(1, N + 1):
    if comp[r]:
        continue
    comp[r] = r
    comp_size[r] = 1
    stack = [r]
    while stack:
        v = stack.pop()
        for w in G[v]:
            if comp[w]:
                if color[v] == color[w]:
                    is_bipartite[r] = 0
                continue
            comp[w] = r
            comp_size[r] += 1
            color[w] = 1 ^ color[v]
            stack.append(w)
a, b, c = 0, 0, 0  # point,odd,even
for r in range(1, N + 1):
    if r != comp[r]:
        continue
    if comp_size[r] == 1:
        a += 1
    elif is_bipartite[r]:
        c += 1
    else:
        b += 1
x = 2 * a * N - a * a + b * b + 2 * b * c + 2 * c * c
print(x)

-input = sys.stdin.readline -N, M = list(map(int, input().split())) -UV = [[int(x) for x in row.split()] for row in sys.stdin.readlines()] -graph = [[] for _ in range(N + 1)] -for u, v in UV: -    graph[u].append(v) -    graph[v].append(u) -color = [None] * (N + 1) - - -def calc_comp_data(v): -    c = 0 -    q = [v] -    color[v] = 0 -    is_bipartite = True -    size = 1 -    while q: -        qq = [] -        c ^= 1 -        for x in q: -            for y in graph[x]: -                if color[y] is None: -                    color[y] = c -                    qq.append(y) -                    size += 1 -                elif color[y] == c: -                    continue -                else: -                    is_bipartite = False -        q = qq -    return size, is_bipartite - - -size = [] -is_bipartite = [] -for v in range(1, N + 1): -    if color[v] is not None: +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N, M = list(map(int, readline().split())) +m = list(map(int, read().split())) +G = [[] for _ in range(N + 1)] +for a, b in zip(m, m): +    G[a].append(b) +    G[b].append(a) +comp = [0] * (N + 1) +comp_size = [0] * (N + 1) +is_bipartite = [1] * (N + 1) +color = [0] * (N + 1) +for r in range(1, N + 1): +    if comp[r]: -    x, y = calc_comp_data(v) -    size.append(x) -    is_bipartite.append(y) -size, is_bipartite -n_point = sum(1 if s == 1 else 0 for s in size) -n_component = len(size) -n_bipartitle = sum(1 if s >= 2 and bl else 0 for s, bl in zip(size, is_bipartite)) -answer = 0 -for s, bl in zip(size, is_bipartite): -    if s == 1: -        # 第1成分が1点のとき -        answer += N -    elif not bl: -        # 第1成分が2点以上、非二部グラフ -        # 成分の個数が足される -        answer += (n_component - n_point) + s * n_point +    comp[r] = r +    comp_size[r] = 1 +    stack = [r] +    while stack: +        v = stack.pop() +        for w in G[v]: +            if comp[w]: +                if color[v] == color[w]: +                    is_bipartite[r] = 0 +                continue +            comp[w] = r +            comp_size[r] += 1 +            color[w] = 1 ^ color[v] +            stack.append(w) +a, b, c = 0, 0, 0  # point,odd,even +for r in range(1, N + 1): +    if r != comp[r]: +        continue +    if comp_size[r] == 1: +        a += 1 +    elif is_bipartite[r]: +        c += 1 -        # 第1成分が2点以上の二部グラフ -        # 相手が2点以上の二部グラフなら、2つできる -        answer += (n_component - n_point) + n_bipartitle + s * n_point -print(answer) +        b += 1 +x = 2 * a * N - a * a + b * b + 2 * b * c + 2 * c * c +print(x)