Problem:
Drawing Lots Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.   In the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swaped by the first horizontal line which connects second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2) and (3, 4), then obtain "4 1 2 5 3" in the bottom. Your task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting pints, numbers 1, 2, 3, ..., w are assigne to the vertical lines from left to right. Input  w  n  a 1 , b 1  a 2 , b 2 .
. a n , b n   w ( w ≤ 30) is the number of vertical lines. n ( n ≤ 30) is the number of horizontal lines. A pair of two integers a i and b i delimited by a comma represents the i -th horizontal line. Output The number which should be under the 1st (leftmost) vertical line The number which should be under the 2nd vertical line : The number which should be under the w -th vertical line  Sample Input 5
4
2,4
3,5
1,2
3,4 Output for the Sample Input 4
1
2
5
3

Solution (Python):
w = int(raw_input())
n = int(raw_input())
list = []

for i in range(1, w+1):
    list.append(i)
    


for j in range(1, n+1):
    num1, num2 = map(int, raw_input().split(","))
    temp = list[num1-1]
    list[num1-1]=list[num2-1]
    list[num2-1]=temp
    

for k in range(0, w):
    print list[k]

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

Solution (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")

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

amida = []
amida.append(-1)
for i in range(w):
    amida.append(i)

for l in range(n):
    a,b = [int(i) for i in input().split(",")]
    tmp = amida[a]
    amida[a] = amida[b]
    amida[b] = tmp

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

Solution (Python):
a=[i+1 for i in range(int(input()))]
for _ in[0]*int(input()):
 s,t=map(lambda x:int(x)-1,input().split(','))
 a[s],a[t]=a[t],a[s]
print(*a,sep='\n')

Solution (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:
 if s:print(s)

Solution (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:s and print(s)

Solution (Python):
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])

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

Solution (Python):

w = int(input())
ans = [i + 1 for i in range(w)]
loop = int(input())


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


for i in ans:
    print(i)

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

Solution (Python):
w = int(input())
n = int(input())
lst = [i + 1 for i in range(w)]
def swap(t):
  a,b = t
  temp = lst[a-1]
  lst[a-1] = lst[b-1]
  lst[b-1] = temp
for i in range(n):
  swap(tuple(map(int,input().split(","))))
for i in range(w):
  print(lst[i])

Solution (Python):
if __name__ == '__main__':
    w = int(input())
    result = [i + 1 for i in range(w)]

    n = int(input())

    permutations = []
    for _ in range(n):
        permutations.append(map(lambda x: int(x) - 1, input().split(',')))

    for i, j in permutations:
        result[j], result[i] = result[i], result[j]

    print("\n".join(map(str, result)))

Solution (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]

Solution (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:s and print(s)

Solution (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')

Solution (Python):
a = [i for i in range(int(input()) + 1)]
for _ in range(int(input())):
    x, y = map(int, input().split(","))
    a[x], a[y] = a[y], a[x]
[print(e) for e in a[1:]]

Solution (Python):
w=input()
n=input()
A=[ i+1 for i in range(w)]

for i in range(n):
	a,b=map(int, raw_input().split(","))
	ta=A[a-1]
	tb=A[b-1]
	A[a-1]=tb
	A[b-1]=ta

for i in A:
	print i

Solution (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)

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

amida = []

for i in range(0,w+1):
    amida.append(i)
    
for i in range(n):
    ai,bi = map(int,input().split(","))
    aa = amida[ai]
    bb = amida[bi]
    amida[ai] = bb
    amida[bi] = aa
    
for i in range(1,w+1):
    print(amida[i])

Solution (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]

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

Solution (Python):



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

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

Solution (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])

Solution (Python):
w = input()
bar = range(w)
n = input()
p = 0
while p != n:
    rev = raw_input().split(',')
    bar[int(rev[0])-1],bar[int(rev[1])-1] = bar[int(rev[1])-1],bar[int(rev[0])-1]
    p += 1
for i in bar:
    print i+1

Solution (Python):
import sys

w = int(sys.stdin.readline())
n = int(sys.stdin.readline())
lines = list()
for line in xrange(n):
    line = sys.stdin.readline()
    line = line.strip()
    lines.append(map(int, line.split(",")))

def swap(yoko, nums):
    a, b = yoko
    a -= 1
    b -= 1
    tmp = nums[a]
    nums[a] = nums[b]
    nums[b] = tmp

nums = range(1, w+1)
for yoko in lines:
    swap(yoko, nums)

for i in nums:
    print i

Solution (Python):
list = [x+1 for x in xrange(int(input()))]
tmp = 0
for i in xrange(int(input())):
    ch = [int(x) for x in raw_input().split(",")]
    tmp = list[ch[0]-1]
    list[ch[0]-1] = list[ch[1]-1]
    list[ch[1]-1] = tmp
for x in list:
    print x

Solution (Python):
w=input()
list=range(0,w+1)
n=input()
for i in xrange(n):
    a,b=map(int,raw_input().split(','))
    tmp=list[a]
    list[a]=list[b]
    list[b]=tmp
for i in xrange(w):
    print list[i+1]

Solution (Python):
w=input()
list=range(0,w+1)
n=input()
for i in xrange(n):
    a,b=map(int,raw_input().split(','))
    tmp=list[a]
    list[a]=list[b]
    list[b]=tmp
for i in list[1:]:
    print i

Solution (Python):

while 1:
    try:
        v = input()
        h = input()
        n = range(1, v+1)
        for i in xrange(h):
            vl = map(int, raw_input().split(","))
            n[vl[0]-1], n[vl[1]-1] = n[vl[1]-1], n[vl[0]-1]
        for i in xrange(v):
            print n[i]
            
    except EOFError:
        break

Solution (Python):
n = input()
amd = [i+1 for i in range(n)]

m = input()

for i in range(m):
    a,b = map(int, raw_input().split(','))
    amd[a-1],amd[b-1] = amd[b-1],amd[a-1]

for am in amd :
    print am

Solution (Python):
list=range(0,input()+1)
for i in xrange(input()):
    a,b=map(int,raw_input().split(','))
    list[a],list[b]=list[b],list[a]
for i in list[1:]:
    print i

Solution (Python):




def func(L, pairs):
    if pairs:
        a, b = pairs.pop(0)
        L[a], L[b] = L[b], L[a]
        return func(L, pairs)
    else:
        return L


def main():
    w = int(raw_input())
    L = range(w + 1)
    n = int(raw_input())
    pairs = []
    for i in xrange(n):
        pairs.append([int(x) for x in raw_input().split(",")])

    for i in func(L, pairs)[1:]:
        print i


if __name__ == '__main__':
    main()

Solution (Python):
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
    a.append(map(int, raw_input().split(',')))
r = range(1, w + 1)
for i in a:
    tmp = r[i[0] - 1]
    r[i[0] - 1] = r[i[1] - 1]
    r[i[1] - 1] = tmp
for i in r:
    print i

Solution (Python):
amida = range(int(raw_input()) + 1)
for i in range(int(raw_input())):
    a, b = map(int, raw_input().split(','))
    amida[a], amida[b] = amida[b], amida[a]
for i in range(1, len(amida)): print amida[i]

Solution (Python):
amida = range(int(raw_input()) + 1)
for i in range(int(raw_input())):
    a, b = map(int, raw_input().split(','))
    amida[a], amida[b] = amida[b], amida[a]
for i in range(1, len(amida)): print amida[i]

Solution (Python):
amida = range(int(raw_input()) + 1)
for i in range(int(raw_input())):
    a, b = map(int, raw_input().split(','))
    amida[a], amida[b] = amida[b], amida[a]
for i in range(1, len(amida)): print amida[i]

Solution (Python):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = [i + 1 for i in xrange(int(stdin.readline()))]
for _, line in zip(xrange(int(stdin.readline())), stdin):
    a, b = (int(t) - 1 for t in line.split(','))
    L[a], L[b] = L[b], L[a]
for i in L:
    print(i)

Solution (Python):
words = []
w = input()
n = input()
change = []
for val in range(1,n+1):
	x = map(int,raw_input().split(','))
	change.append(x)
kekka = range(1,w+1)
for val in range(1,n+1):
	a = kekka[change[val-1][0]-1]
	b = kekka[change[val-1][1]-1]
	kekka[change[val-1][0]-1] = b
	kekka[change[val-1][1]-1] = a
for x in kekka:
	print x

Solution (Python):
'''
Created on Mar 21, 2013

@author: wukc
'''

import sys
w=int(sys.stdin.readline())
n=int(sys.stdin.readline())
a=[i for i in range(w+1)]

for i in range(n):
    l=sys.stdin.readline()
    x,y=map(int,l.split(","))
    a[x],a[y]=a[y],a[x]
    
print("\n".join(map(str,a[1:])))

Solution (Python):
import sys
l = range(input())
n = input()
for line in sys.stdin:
    [a,b] = [int(x) for x in line.split(',')]
    tmp = l[a-1]
    l[a-1] = l[b-1]
    l[b-1] = tmp
for i in l:
    print i+1

Solution (Python):

def change(z,x,y):
    tmp = z[x-1]
    z[x-1] = z[y-1]
    z[y-1] = tmp
    return z


a = int(raw_input())
b = int(raw_input())

c = range(a)
while b > 0:
    in1,in2 = map(int,raw_input().split(','))
    c = change(c,in1,in2)
    b -= 1


for p in c:
    print p+1

Solution (Python):
import sys


class Walker:
    def __init__(self, n):
        self.start = n
        self.state = n

    def jump(self, pair):
        a, b = pair
        if self.state == a:
            self.state = b
        elif self.state == b:
            self.state = a
        return self



def to_pair(str):
    ab = str.split(',')
    a = int(ab[0])
    b = int(ab[1])
    return (a, b)





lines = sys.stdin.readlines()

w = int(lines.pop(0))
walkers = map((lambda x: Walker(x)), range(1, w+1))

lines.pop(0)

bars = map((lambda x: to_pair(x)), lines)

walkers_end = []
for walker in walkers:
    walker = reduce((lambda wkr, p: wkr.jump(p)), bars, walker)
    walkers_end.append(walker)
walkers_end.sort(lambda a, b: cmp(a.state, b.state))

for w in walkers_end:
    print w.start

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

for e in x:
    print e

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

Solution (Python):


amida = []

def main():
	num_vlines = int(raw_input());
	num_wlines = int(raw_input());

	init_amida(num_vlines)

	count = 0;
	while count < num_wlines :
		ab = raw_input().strip().split(',')
		
		
		transposition(int(ab[0]), int(ab[1]))
		
		
		count += 1

	for i in range(1, num_vlines + 1):
		print amida[i]


def init_amida(num_vlines):
	for i in range(num_vlines + 1):
		amida.append(i)

	

def transposition(a, b):
	tmp = amida[a]
	amida[a] = amida[b]
	amida[b] = tmp

main()

Solution (Python):


import sys


w = 0
n = 0
lots = None

for (i, line) in enumerate(sys.stdin):
	if i == 0:
		w = int(line)
		lots = [lot for lot in xrange(1, w+1)]
	elif i == 1:
		n = int(line)
	else:
		a, b = map(int, line.split(","))
		lots[b-1], lots[a-1] = lots[a-1], lots[b-1]

for i in xrange(w):
	print lots[i]

Solution (Python):
w = [x+1 for x in range(input())]
for x in range(input()):
    a, b = map(int, raw_input().split(","))
    tempor = w[a-1]
    w[a-1] = w[b-1]
    w[b-1] = tempor
for x in range(len(w)):
    print w[x]

Solution (Python):
import sys

def main():
	tate = int(raw_input())
	result = []
	for i in range(1, tate+1):
		result.append(i)

	yoko = int(raw_input())

	for line in sys.stdin.readlines():
		x1, x2 = map(int, line.split(","))
		x1 -= 1
		x2 -= 1
		temp = result[x2]
		result[x2] = result[x1]
		result[x1] = temp

	for num in result:
		print num
	


if __name__ == '__main__':
	main()

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

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

Solution (Python):
W=range(1,input()+1)
N=range(input())
for i in N:
  a,b=map(int,raw_input().split(","))
  W[a-1],W[b-1]=W[b-1],W[a-1]
for e in W:print e

Solution (Python):
W=range(1,input()+1)
N=range(input())
for i in N:
  a, b = map(int,raw_input().split(","))
  W[a-1], W[b-1] = W[b-1], W[a-1]
for e in W: print e

Solution (Python):
W=range(1, input()+1)
N=range(input())
for i in N:
  a, b = map(int,raw_input().split(","))
  W[a-1], W[b-1] = W[b-1], W[a-1]
for e in W: print e

Solution (Python):
W=range(1, input()+1)
N=range(input())
for i in N:
  a, b = map(int,raw_input().split(","))
  W[a-1], W[b-1] = W[b-1], W[a-1]
for e in W:
  print e

Solution (Python):
W = range(1, input()+1)
for i in range(input()):
  a, b = map(int,raw_input().split(","))
  W[a-1], W[b-1] = W[b-1], W[a-1]
for e in W:
  print e

Solution (Python):
W = range(input()+1)
for i in range(input()):
  a, b = map(int,raw_input().split(","))
  W[a], W[b] = W[b], W[a]
for e in W[1:]:
  print e

Solution (Python):
W=range(input()+1)
for i in range(input()):
  a,b=map(int,raw_input().split(","))
  W[a],W[b]=W[b],W[a]
for e in W[1:]:print e

Solution (Python):
W=range(input()+1)
for i in range(input()):
  a,b=map(int,raw_input().split(","))
  W[a], W[b] = W[b], W[a]
for e in W[1:]:print e

Solution (Python):


import sys


lineNumber = 0

for line in sys.stdin.readlines():
    lineNumber += 1

    
    List = map(int, line.strip().split(","))

    
    if lineNumber == 1:
        w = List[0]
        array = [i for i in xrange(1, w+1)]
        continue
    if lineNumber == 2: continue

    
    [a, b] = List
    a -= 1; b -= 1

    
    buf = array[a]
    array[a] = array[b]
    array[b] = buf
    
for i in xrange(w):
    print array[i]

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

Solution (Python):
w = int(raw_input())
n = int(raw_input())

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

for i in s:
    print i

Solution (Python):
num = [x for x in range(1,int(raw_input())+1)]
n = int(raw_input())
for i in range(n):
    s,t = map(int, raw_input().split(','))
    num[s-1],num[t-1] = num[t-1],num[s-1]
for j in num: print j

Solution (Python):
w=int(raw_input())
n=int(raw_input())

ret=range(1,w+1)

for i in range(0,n):
    ab = map(int,raw_input().split(","))
    tmp = ret[ab[0]-1]
    ret[ab[0]-1] = ret[ab[1]-1]
    ret[ab[1]-1] = tmp

for i in ret:
    print i

Solution (Python):
w = int(raw_input())
bars = []
ans = [0 for i in range(w)]

for i in range(int(raw_input())):
	bars.append(map(int, raw_input().split(',')))

for i, j in zip(range(1, w+1),range(0,w)):
	for bar in bars:
		if bar[0] == i:
			i = bar[1]
		elif bar[1] == i:
			i = bar[0]
	ans[i-1] = j+1

for s in ans:
	print s

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

Solution (Python):
a = range(int(raw_input()) + 1)
for i in range(int(raw_input())):
    p, q = map(int, raw_input().split(','))
    a[p], a[q] = a[q], a[p]
for p in a[1:]:
    print p

Solution (Python):
w = int(raw_input())
n = int(raw_input())

arr = range(1, w+1)
for i in range(n):
  a, b = map(int, raw_input().split(','))
  arr[a-1], arr[b-1] = arr[b-1], arr[a-1]

for a in arr:
  print '%d'%a

Solution (Python):
w = int(raw_input())
n = int(raw_input())
a = []
for i in range(n):
  a.append(map(int, raw_input().split(',')))
r = range(1,w + 1)
for i in a:
  tmp = r[i[0] - 1]
  r[i[0] - 1] = r[i[1] - 1]
  r[i[1] - 1] = tmp
for i in r:
  print i

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

Solution (Python):
v = int(input())
h = int(input())

l = [i for i in range(1, v + 1)]
for i in range(h):
    n, m = input().split(',')
    n = int(n) - 1
    m = int(m) - 1
    l[n], l[m] = l[m], l[n]

for i in l:
    print(i)

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

Solution (Python):
n=int(input())
k=int(input())

li=[]
for i in range(1, n+1):
    li.append(i)
    

for i in range(k):
    x=list(map(int,input().split(",")))
    li[x[0]-1]^=li[x[1]-1]
    li[x[1]-1]^=li[x[0]-1]
    li[x[0]-1]^=li[x[1]-1]
    
    
for i in range(n):
    print(li[i])

Solution (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)

Solution (Python):

line = []
for i in range(1,int(input()) + 1):line.append(i)


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

for s in line:print(s)

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

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

for i in wlst:
    print(i)

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

Solution (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)

Solution (Python):
numList = []
for i in range(int(input())):
    numList.append(i + 1)

for i in range(int(input())):
    a, b = list(map(int, input().split(',')))
    a, b = a - 1, b - 1
    tmp = numList[a]
    numList[a] = numList[b]
    numList[b] = tmp

for num in numList:
    print(num)

Solution (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])

Solution (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)

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

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

for i in range(N):
	a,b=list(map(int, input().split(',')))
	field[i][a-1]=b-1;
	field[i][b-1]=a-1;

result=[0 for i in range(W)];
for i in range(W):
	now=i;
	for j in range(N):
		if(field[j][now]!=-1):
			now=field[j][now];
	result[now]=i+1;

for i in result:
	print(i);

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

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

for v in lv:
    print(v)

Solution (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)

Solution (Python):
n = int(input())
h = int(input())
arr = list(range(1, n + 1))
for _ in range(h):
    a, b = map(int, input().split(','))
    arr[a - 1], arr[b - 1] = arr[b - 1], arr[a - 1]
for ai in arr:
    print(ai)

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

A = list()
B = list()

S = [i for i in range(1, w + 1)]
G = [0 for i in range(w)]

for i in range(n) :
    a , b = map(int, input().split(","))
    A.append(a)
    B.append(b)
    
for i in range(1, w + 1) :
    g = i
    for j in range(n) :
        if(A[j] == g) :
            g = B[j]
        elif(B[j] == g) :
            g = A[j]
        else :
            pass
    G[g - 1] = i
    
for i in range(w) :
    print(G[i])

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

L = list(range(1,w+1))

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

for i in L:
    print(i)

Solution (Python):
w = int(input())
n = int(input())
a = range(w)
a = list(a)
for i in range(n):
    p, q = map(int, input().split(","))
    t = a[p - 1]
    a[p - 1] = a[q - 1]
    a[q - 1] = t
for each in a:
    print(each + 1)

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

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

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

Solution (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])

Solution (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)

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

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

Solution (Python):






import sys
import math
import array


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()



















def main():

    W = int(input())
    N = int(input())
    AB = [[int(x)-1 for x in input().split(',')] for i in range(N)]
    
    ans = list(range(1, W+1))

    for ab in AB:
        ans[ab[0]], ans[ab[1]] = ans[ab[1]], ans[ab[0]]

    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == '__main__':

	line = int(input())
	A = [i+1 for i in range(line)]
	n = int(input())

	for _ in range(n):
		j,k = map(int,input().split(","))

		A[j-1],A[k-1] = A[k-1],A[j-1]

	for i in range(line):
		print(A[i])

Solution (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])

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

Solution (Python):
def amida():
    line_number=int(input())
    line=[]
    for j in range(1,line_number+1):
        line.append(j)
    yoko=int(input())
    for i in range(yoko):
        a,b=map(int,input().split(","))
        line[a-1],line[b-1]=line[b-1],line[a-1]
    return line
while True:
    try:
        ans=amida()
        for i in range(int(len(ans))):
            print(ans[i])
        break
    except:break

Solution (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)

Solution (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")

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

Solution (Python):
if __name__ == '__main__':
    w = int(input())
    n = int(input())
    lst = []
    anslst = [0 for i in range(w)]
    for i in range(n):
        a, b = map(int, input().split(','))
        lst.append((a,b))
    for i in range(1,w+1):
        x = i 
        for (f,s) in lst:
            if f == x:
                x = s
            elif s == x:
                x = f
        anslst[x-1] = i
    for n in anslst:
        print(n)

Solution (Python):


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

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

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

Solution (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])

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

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

def swap(nlist,i,j):
    temp = nlist[i-1]
    nlist[i-1] = nlist[j-1]
    nlist[j-1] = temp
    return nlist

nlist = [i+1 for i in range(w)]
for i in range(n):
    i,j = [int(a) for a in input().split(',')]
    swap(nlist,i,j)
for i in nlist:
    print(i)

Solution (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)

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

alist = []
blist = []
for _ in range(n):
    a, b = map(int, input().split(","))
    alist.append(a)
    blist.append(b)

ans = [0] * w

for i in range(1, w+1):
    position = i
    for a, b in zip(alist, blist):
        if a == position:
            position = b
        elif b == position:
            position = a

    ans[position-1] = i

for a in ans:
    print(a)

Solution (Python):
w = int(input())    
n = int(input())    
combine = [list(map(int, input().split(","))) for _ in range(n)]   
answer = list(range(1, w+1))    


for com in combine:
    x, y = com
    answer[x-1], answer[y-1] = answer[y-1], answer[x-1]


print('\n'.join(map(str, answer)))

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

Solution (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")

Solution (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]

Solution (Python):
ans=list(range(1,int(input())+1))
for i in range(int(input())):
    a,b=map(lambda x: int(x)-1,input().split(","))
    ans[a],ans[b]=ans[b],ans[a]
for i in ans:
    print(i)

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