n,q=list(map(int,input().split()))

exist=set([1])

cup=list(range(n+2))

now=1

exist.add(cup[now-1])

exist.add(cup[now+1])

for i in range(q):

    a,b=list(map(int,input().split()))

    if now==a:now=b

    elif now==b:now=a

    tmp=cup[a]

    cup[a]=cup[b]

    cup[b]=tmp

    exist.add(cup[now-1])

    exist.add(cup[now+1])

exist=list(exist)

ans=0

for i in range(len(exist)):

    if exist[i]!=0 and exist[i]!=n+1:ans+=1

print(ans)
n,q=list(map(int,input().split()))

exist=[False]*(n+2)

exist[1]=True

cup=list(range(n+2))

now=1

exist[cup[now-1]]=True

exist[cup[now+1]]=True

for i in range(q):

    a,b=list(map(int,input().split()))

    if now==a:now=b

    elif now==b:now=a

    tmp=cup[a]

    cup[a]=cup[b]

    cup[b]=tmp

    exist[cup[now-1]]=True

    exist[cup[now+1]]=True

ans=0

for i in range(1,n+1):

    if exist[i]:ans+=1

print(ans)

n, q = list(map(int, input().split()))
exist = set([1])
cup = list(range(n + 2))
now = 1
exist.add(cup[now - 1])
exist.add(cup[now + 1])
for i in range(q):
    a, b = list(map(int, input().split()))
    if now == a:
        now = b
    elif now == b:
        now = a
    tmp = cup[a]
    cup[a] = cup[b]
    cup[b] = tmp
    exist.add(cup[now - 1])
    exist.add(cup[now + 1])
exist = list(exist)
ans = 0
for i in range(len(exist)):
    if exist[i] != 0 and exist[i] != n + 1:
        ans += 1
print(ans)

n, q = list(map(int, input().split()))
exist = [False] * (n + 2)
exist[1] = True
cup = list(range(n + 2))
now = 1
exist[cup[now - 1]] = True
exist[cup[now + 1]] = True
for i in range(q):
    a, b = list(map(int, input().split()))
    if now == a:
        now = b
    elif now == b:
        now = a
    tmp = cup[a]
    cup[a] = cup[b]
    cup[b] = tmp
    exist[cup[now - 1]] = True
    exist[cup[now + 1]] = True
ans = 0
for i in range(1, n + 1):
    if exist[i]:
        ans += 1
print(ans)

-exist = set([1]) +exist = [False] * (n + 2) +exist[1] = True -exist.add(cup[now - 1]) -exist.add(cup[now + 1]) +exist[cup[now - 1]] = True +exist[cup[now + 1]] = True -    exist.add(cup[now - 1]) -    exist.add(cup[now + 1]) -exist = list(exist) +    exist[cup[now - 1]] = True +    exist[cup[now + 1]] = True -for i in range(len(exist)): -    if exist[i] != 0 and exist[i] != n + 1: +for i in range(1, n + 1): +    if exist[i]: