Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

Python: w = int(input().replace("\n", ""))
n = []
for i in range(int(input().replace("\n", ""))):
    n.append([int(v) for v in input().replace("\n", "").split(",")])

m = [0] * (w + 1)
for i in range(1, w + 1):
    step = i
    for j in range(0, len(n)):
        if n[j][0] == step:
            step = n[j][1]
        elif n[j][1] == step:
            step = n[j][0]
    m[step] = i
del m[:1]
print("\n".join(map(str, m)))

Python: w=eval(input())
n=eval(input())
edge=[]
for i in range(n):
    edge.append(tuple(map(int,input().split(','))))
for i in range(1,w+1):
    temp=i
    for j in range(n):
        if temp in edge[n-j-1]:
            temp=edge[n-j-1][edge[n-j-1].index(temp)-1]
    print(temp)

Python: #!/usr/bin/env python3
# -*- coding: utf-8 -*-



def main():
    w = int(input())
    n = int(input())

    xs = [i for i in range(w+1)]
    for _ in range(n):
        a, b = map(int, input().split(","))

        xs[a], xs[b] = xs[b], xs[a]

    for i in range(1, w+1):
        print(xs[i])

if __name__ == "__main__": main()

Python: w = int(input())
n = int(input())

amida = [i for i in range(1, w + 1)]
for _ in range(n):
    a, b = [int(i) - 1 for i in input().split(",")]
    amida[a], amida[b] = amida[b], amida[a]

for x in amida:
    print(x)

Python: w = int(input())
n = int(input())
li = list(range(1, w + 1))
for i in range(n):
    a, b = map(int, input().split(','))
    a -= 1; b -= 1
    li[a], li[b] = li[b], li[a]

for x in li:
    print(x)

Python: n = int(input())
m = int(input())
p = list(range(n+1))
for i in range(m):
    a, b = map(int, input().split(","))
    p[a], p[b] = p[b], p[a]

for v in p[1:]:
    print(v)

Python: a=int(input())
b=int(input())
c=range(1,b+1)
for i in range(a):
    d=map(int,raw_input().split())
    c[d[0]],c[d[-1]]=c[d[-1]],c[d[0]]
for i in c:print(i)

Python: arr = [i + 1 for i in range(int(input()))]
m = int(input())
for i in range(m):
    inp = list(map(int, input().split(",")))
    tmp = arr[inp[0] - 1]
    arr[inp[0] - 1] = arr[inp[1] - 1]
    arr[inp[1] - 1] = tmp
for i in range(len(arr)):
    print(arr[i])

Python: w = int(input())
n = int(input())
ans = [0 for i in range(w)]
list = []

for i in range(n):
    ll = input().split(",")
    a, b = ll[0], ll[1]
    a = int(a)
    b = int(b)
    list.append([a,b])

# print(list)
for i in range(1,w+1):
    position = i-1

    for ll in list:
        a, b = ll[0], ll[1]
        if position == a-1:
            position = b-1
        elif position == b-1:
            position = a-1
        else:
            pass
    ans[position] = i
for j in ans:
    print(j)

Python: #!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

w = int(input())
n = int(input())
s = []

for _ in range(n):
    x = input().split(',')
    s.append((int(x[0]), int(x[1])))

result = [i for i in range(1, w+1)]

for x, y in s:
    result[x-1], result[y-1] = result[y-1], result[x-1]

for x in result:
    print(x)

Python: w = eval(input())
n = eval(input())
numlist = [item for item in range(1, w + 1)]
for t in range(n):
	i, j = [eval(item) - 1 for item in input().split(',')]
	numlist[i], numlist[j] = numlist[j], numlist[i]
for item in numlist:
	print(item)

Python: w = int(input())
n = int(input())
lst = [i for i in range(1, w+1)]
for i in range(n) :
    a, b = map(int, input().split(','))
    lst[a-1], lst[b-1] = lst[b-1], lst[a-1]
for i in lst :
    print(i)

Python: # coding: utf-8

w = int(raw_input())
n = int(raw_input())

yoko = []
for i in range(n):
	data = map(int, raw_input().split(","))
	yoko.append(data)

ans = []
for i in range(1,w+1):
	ans.append(0)

for num in range(1,w+1):
#	deb.printdebug1(num, debug)
	direction = num
	for c in yoko:
		if c[0] == direction:
#			deb.printdebug2(direction, debug)
#			deb.printdebug2(c[1], debug)
			direction = c[1]
		elif c[1] == direction:
#			deb.printdebug2(direction, debug)
#			deb.printdebug2(c[1], debug)
			direction = c[0]
	ans[direction-1] = num

for i in ans:
	print(i)

Python: a = []
b = []
numbers_s = []
numbers_g = []

w = int(input())
n = int(input())

for i in range(0, n):
    temp_a, temp_b = input().split(',')
    a.append(int(temp_a))
    b.append(int(temp_b))

for i in range(0, w):
    numbers_s.append(i+1)
    numbers_g.append(0)

for i in range(0, w):

    temp_idx = i+1

    for j in range(0, n):
        if temp_idx == a[j]: temp_idx = b[j]
        elif temp_idx == b[j]: temp_idx = a[j]

    numbers_g[temp_idx - 1] = i+1

for i in range(0, len(numbers_g)):
    print(numbers_g[i])

Python: w=list(range(int(input())))
sw=[list(map(int,input().split(","))) for i in range(int(input()))]
for i in sw:
    w[i[0]-1],w[i[1]-1]=w[i[1]-1],w[i[0]-1]
[print(i+1) for i in w]

Python: w = int(input())
s = [i for i in range(1,w+1)]
n = int(input())
for i in range(n):
    a = list(map(int, input().split(',')))
    s[a[0]-1],s[a[1]-1] = s[a[1]-1],s[a[0]-1]

for i in s:
    print(i)

Python: w=int(input())
n=int(input())
a=[]
for i in range(w):
    a.append(i+1)
for i in range(n):
    m, n= map(int,input().split(','))
    temp=a[m-1]
    a[m-1]=a[n-1]
    a[n-1]=temp
for i in range(w):
    print(a[i])

Python: # coding: utf-8
w = int(input())
ans = [i + 1 for i in range(w)]
loop = int(input())

# swap
for _ in range(loop):
    left, right = map(int, input().split(","))
    ans[left-1], ans[right-1] = ans[right-1], ans[left-1]

# result
for i in ans:
    print(i)

Python: a=list(range(int(input())+1))
for _ in[0]*int(input()):
 s,t=map(int,input().split(','))
 a[s],a[t]=a[t],a[s]
for s in a:print(s+1)

Python: import sys
w = int(input())
n = int(input())
l = list()
for _ in range(n):
    l.append(list(map(int,input().split(","))))

res = [0 for _ in range(w)]
for i in range(1,w+1):
    tgt = i
    for num in l:
        if tgt in num:
            if num.index(tgt) == 1:
                tgt = num[0]
            else:
                tgt = num[1]
    res[tgt-1] = i

for x in res:
    print(x)

Python: w = int(input())
n = int(input())
nums = list(range(1, w + 1))
for i in range(n):
    a, b = map(int, input().split(","))
    c = nums[a - 1]
    nums[a - 1] = nums[b - 1]
    nums[b - 1] = c

for i in range(w):
    print(nums[i])

Python: w = int(input())
n = int(input())
array = [[i for i in input().split(",")]for i in range(n)]
a = -1
b = 1
c = False
d = [0 for i in range(w)]
for i in range(w):
    for i2 in range(n):
        if (i+1 == int(array[i2][0]) or i+1 == int(array[i2][1])) and a == -1:
            a = i2
            if i+1 == int(array[i2][0]):
                b = int(array[i2][1])
            else:
                b = int(array[i2][0])
            c = True
        if c and a < i2 and (b == int(array[i2][0]) or b == int(array[i2][1])):
            a = i2
            if b == int(array[i2][0]):
                b = int(array[i2][1])
            else:
                b = int(array[i2][0])
    d[b-1] = i+1
    a = -1
    b = i+1
    c = False
for i in range(w):
    print(d[i])

Python: w = int(input())
n = int(input())
Ami = []
Num = []
for i in range(n):
    Ami.append(list(map(int,input().split(","))))
print(Ami)
for i in range(1,w+1):
    pos = i
    for j in range(n):
        if pos == Ami[j][0]:
            pos = Ami[j][1]
        elif pos == Ami[j][1]:
            pos = Ami[j][0]
    Num.append([pos,i])
Num = sorted(Num)
for k in range(0,w):
    print(Num[k][1])

Python: a=list(range(int(input())+1))
for _ in[0]*int(input()):s,t=map(int,input().split(','));a[s],a[t]=a[t],a[s]
[print(s)for s in a if s]