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: # -*- coding: utf-8 -*-

import sys

def amida(w, side_bar):
    result = []
    side_bar.reverse()
    for x in range(1, w+1):
        status = x
        for bar in side_bar:
            if status == bar[0]:
                status = bar[1]
            elif status == bar[1]:
                status = bar[0]
        result.append(status)
    return result

def main():
    W = int(input())
    N = int(input())
    side_bar = [tuple(map(int, input().split(','))) for line in range(N)]
    result = amida(W, side_bar)
    for r in result:
        print(r)

if __name__ == '__main__':
    main()

Python: def get_another_num(data, me):
    if data[0] == me:
        return data[1]
    else:
        return data[0]


if __name__ == '__main__':
    # ??????????????\???
    v_lines = 5
    h_lines = 4
    data = [(2, 4), (3, 5), (1, 2), (3, 4)]

    # ????????????????????????
    results = [0] * (v_lines + 1)
    for i in range(1, v_lines + 1):
        me = i
        for amida in data:
            if me in amida:
                me = get_another_num(amida, me)
        results[me] = i

    # ???????????¨???
    for i in range(1, v_lines + 1):
        print(results[i])

Python: def main():
    LIST=[]
    for i in range(int(input())):
        LIST.append(i+1)

    for j in range(int(input())):
        a,b=map(int,input().split(","))
        LIST[a-1],LIST[b-1]=LIST[b-1],LIST[a-1]

    for i in LIST:
        print(i)

Python: def play():
    result_dic = {}    
    for i in range(tate):
        depart = i+1
        arrival = drawing_lots[depart][0]
        arrival = aaa(depart, arrival)
        result_dic[arrival] = depart
    
    for k in sorted(result_dic):
        print(result_dic[k])

def aaa(depart, arrival):
    offset = 0
    for offset, point in enumerate(drawing_lots[arrival]):
        if point == depart:
            break
    
    if offset+1 <= len(drawing_lots[arrival])-1:
        depart = arrival
        arrival = drawing_lots[arrival][offset+1]
        return aaa(depart, arrival)
    else:
        return arrival
        
tate = int(raw_input())
yoko = int(raw_input())

drawing_lots = {}
for num in range(tate):
    drawing_lots[num+1] = []
    
for i in range(yoko):
    horizontal_line = raw_input().split(',')
    left_num = int(horizontal_line[0])
    right_num = int(horizontal_line[1])
    drawing_lots[left_num].append(right_num)
    drawing_lots[right_num].append(left_num)

play()

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

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

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

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

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

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

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

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

for _ in range(n):
    a,b=map(int,input().split(","))
    a-=1
    b-=1
    x=lis[a]
    lis[a]=lis[b]
    lis[b]=x

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

Python: w = int(input())
arr = [i+1 for i in range(w)]
for i in range(int(input())):
    s = input().split(",")
    a,b = int(s[0]), int(s[1])
    temp = arr[a-1]
    arr[a-1] = arr[b-1]
    arr[b-1] = temp
for i in range(w):
    print(arr[i])

Python: W = int(input())
N = int(input())

C = [[-1 for j in range(W)] for i in range(N)]

for i in range(N):
    a, b = map(lambda x:int(x) - 1, input().split(','))
    C[i][a] = b
    C[i][b] = a

A = [-1] * W
for n in range(W):
    j = n
    for i in range(N):
        if C[i][j] >= 0:
            j = C[i][j]
    A[j] = n + 1

for v in A:
    print(v)

Python: table = [(0,0)] * 31
dp = [0] * 31

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

# あみだくじ
for i in range(1,w + 1):
    dest = i
    for j in range(1,h + 1):
        if table[j][0] == dest:
            dest = table[j][1]
        elif table[j][1] == dest:
            dest = table[j][0]
    dp[dest] = i    
    
for i in range(1,w + 1):
    print(dp[i])

Python: w = int(input())
n = int(input())
l = [i for i in range(1, w+1)]

for i in range(n):
    (a,b) = map(lambda x:int(x)-1, input().strip().split(","))
    (l[a],l[b]) = (l[b],l[a])

print(*l,sep="\n")

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

Python: w=input()
amida=[i+1 for i in xrange(w)]
n=input()
for i in xrange(n):
    a,b=map(int,raw_input().split(","))
    amida[a-1],amida[b-1]=amida[b-1],amida[a-1]
for i in xrange(w):
    print(amida[i])

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

Python: w = int(input())
n = int(input())
kuji = [i+1 for i in range(w)]
for _ in range(n):
    a, b = map(int, input().split(','))
    kuji[a-1], kuji[b-1] = kuji[b-1], kuji[a-1]
print(*kuji, sep="\n")

Python: import sys


num = input()
list = {}
for i in range(1, int(num) + 1): 
    list[i] = i
    
for i in range(int(input())) :
    x, y = map(int, input().split(','))
    
    temp = list[x]
    list[x] = list[y]
    list[y] = temp
    
for i in range(1, len(list) + 1):
    print(list[i])

Python: w=int(input())
n=int(input())
d=[list(map(int,input().split(',')))for i in range(n)]

結果=[0]*w
for j in range(w):
	現在位置 = j + 1
	for k1,k2 in d:
		if 現在位置==k1:
			現在位置 = k2
		elif 現在位置==k2:
			現在位置=k1
	結果[現在位置-1]=j+1
print(*結果,sep='\n')

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

Python: w = int(input())
bs = [ x+1 for x in range(w)]
n = int(input())

for i in range(n):
  a, b = map(lambda x:int(x)-1, input().split(','))
  bs[a], bs[b] = bs[b], bs[a]

[print(b) for b in bs]

Python: import math
tate =int(input())
yoko=int(input())
arr = [i+1 for i in range(tate)]
for j in range(yoko):
    rep1,rep2=input().split();
    rep1=int(rep1)-1
    rep2=int(rep2)-1
    arr[rep1],arr[rep2] = arr[rep2],arr[rep1]

for k in range(tate):
    print(arr[k])