Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

Python: #!/usr/bin/env python3
def main():
    w = int(input())
    n = int(input())
    nums = list(range(1, w + 1))
    for _ 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)
if __name__ == '__main__':
    main()

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

Python: w = int(input())
n = int(input())
l = list(range(1,w+1))

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

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

Python: w=int(input())
num=[i+1 for i in range(w)]
n=int(input())
for i in range(n):
	data=list(map(int,input().split(",")))
	a=num[data[0]-1]
	num[data[0]-1]=num[data[1]-1]
	num[data[1]-1]=a
for i in range(w):
	if i==w-1:
		print(num[i],end="\n")
	else:
		print(num[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')