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
a1,b1
a2,b2
.
.
an,bn

w (w ≤ 30) is the number of vertical lines. n (n ≤ 30) is the number of horizontal lines. A pair of two integers ai and bi 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

Try it.
-->



Sample input:
5
4
2,4
3,5
1,2
3,4


Sample output:
4
1
2
5
3

Submission status: Runtime Error

Solution code:
import sys
re = range(input())
for li in sys.stdin:
    [a,b] = [int(x) for x in li.split(",")]
    tmp = re[a-1]
    re[a-1] = re[b-1]
    re[b-1] = tmp
for i in re:
    print i+1

Submission status: Runtime Error

Solution code:
import sys
re = range(int(raw_input()))
for li in sys.stdin:
    [a,b] = [int(x) for x in li.split(",")]
    tmp = re[a-1]
    re[a-1] = re[b-1]
    re[b-1] = tmp
for i in re:
    print i+1

Submission status: Runtime Error

Solution code:
import sys

swapDirections = []
for lincnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
    elif lineCount == 1:
        n = int(line)
    else:
        swapDirections.append(map(int, line.split(',')))

result = range(1, n+1)

for direction in swapDirections:
    ai, bi = direction 
    result[ai], result[bi] = result[bi] , result[ai]

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

Submission status: Runtime Error

Solution code:
import sys

swapDirections = []
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
    elif lineCount == 1:
        n = int(line)
    else:
        swapDirections.append(map(int, line.split(',')))

result = range(1, n+1)

for direction in swapDirections:
    ai, bi = direction 
    result[ai], result[bi] = result[bi] , result[ai]

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

Submission status: Runtime Error

Solution code:
import sys

swapDirections = []
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
    elif lineCount == 1:
        n = int(line)
    else:
        swapDirections.append(map(int, line.split(',')))

result = range(1, n+1)

for direction in swapDirections:
    ai, bi = tuple(direction)
    result[ai], result[bi] = result[bi] , result[ai]

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

Submission status: Runtime Error

Solution code:
import sys

swapDirections = []
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
    elif lineCount == 1:
        n = int(line)
    else:
        swapDirections.append(map(int, line.split(',')))

result = map(str, range(1, n+1))

for direction in swapDirections:
    ai, bi = direction[0], direction[1]
    result[ai], result[bi] = result[bi], result[ai]

print '\n'.join(result)

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin):
    swapDirections = []
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
        elif lineCount == 1:
            n = int(line)
        else:
            swapDirections.append(map(int, line.split(',')))
    
    result = map(str, range(1, n+1))
    
    for direction in swapDirections:
        ai, bi = direction[0], direction[1]
        result[ai], result[bi] = result[bi], result[ai]
                
    print '\n'.join(result)
    
if __name__ == '__main__':
    entory()

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin):
    swapDirections = []
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
        elif lineCount == 1:
            n = int(line)
        else:
            swapDirections.append(map(int, line.split(',')))
    
    result = map(str, range(1, n+1))
    
    for direction in swapDirections:
        ai, bi = direction[0], direction[1]
        result[ai], result[bi] = result[bi], result[ai]
                
    print '\n'.join(result)
    
entory()

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin):
    swapDirections = []
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
        elif lineCount == 1:
            n = int(line)
        else:
            swapDirections.append(map(int, line.split(',')))
    
    result = map(str, range(1, n+1))
    
    for direction in swapDirections:
        ai, bi = direction[0], direction[1]
        result[ai], result[bi] = result[bi], result[ai]
                
    for n in result: print n
    
entory()

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin):
    swapDirections = []
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
        elif lineCount == 1:
            n = int(line)
        else:
            swapDirections.append(map(int, line.split(',')))
    
    result = map(str, range(1, w+1))
    
    for direction in swapDirections:
        ai, bi = direction[0], direction[1]
        result[ai], result[bi] = result[bi], result[ai]
                
    print '\n'.join(result)
    
if __name__ == '__main__':
    entory()

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin):
    swapDirections = []
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
        elif lineCount == 1:
            n = int(line)
        else:
            swapDirections.append(map(int, line.split(',')))
    
    result = map(str, range(1, w+1))
    
    for direction in swapDirections:
        ai, bi = direction[0]-1, direction[1]-1
        result[ai], result[bi] = result[bi], result[ai]
                
    print '\n'.join(result)
    
if __name__ == '__main__':
    entory()

Submission status: Runtime Error

Solution code:
import sys

def entory(fobj=sys.stdin)
    for lineCnt, line in enumerate(fobj):
        if lineCnt == 0:
            w = int(line)
            result = range(1, w+1)
        elif lineCount == 1:
            n = int(line)
        else:
            ai, bi = map(lambda x: int(x)-1, line.split(','))
            result[ai], result[bi] = result[bi], result[ai]
                
    print '\n'.join(result)
    
if __name__ == '__main__':
    entory()

Submission status: Runtime Error

Solution code:
import sys
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
        result = range(1, w+1)
    elif lineCount == 1:
        n = int(line)
    else:
        ai, bi = map(lambda x: int(x)-1, line.split(','))
        result[ai], result[bi] = result[bi], result[ai]
            
print '\n'.join(result)

Submission status: Runtime Error

Solution code:
import sys
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
        result = range(1, w+1)
    elif lineCount == 1:
        n = int(line)
    else:
        ai, bi = map(lambda x: int(x)-1, line.split(','))
        result[ai], result[bi] = result[bi], result[ai]
            
for num in result:
    print num

Submission status: Runtime Error

Solution code:
import sys
result = []
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        w = int(line)
        result = range(1, w+1)
    elif lineCount == 1:
        n = int(line)
    else:
        ai, bi = map(lambda x: int(x)-1, line.split(','))
        result[ai], result[bi] = result[bi], result[ai]
            
for num in result:
    print num

Submission status: Runtime Error

Solution code:
import math
import sys


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

	print result

	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()
import math
import sys


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

	print result

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys


#for line in ["0.0 3.0 -1.0 0.0 -3.0 4.0"]: # expected [-2.000, 2.000, 2.236]
lineNumber = 0
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    List = map(float, line.strip().split())

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

    # set data
    [a, b] = List
    a -= 1; b -= 1

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

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
w = int(raw_input())$
  2 n = int(raw_input())$
  3 a = []$
  4 for i in range(n):$
  5  a.append(map(int, raw_input().split(',')))$
  6 r = range(1,w + 1)$
  7 for i in a:$
  8  tmp = r[i[0] - 1]$
  9  r[i[0] - 1] = r[i[1] - 1]$
 10  r[i[1] - 1] = tmp$
 11 for i in r:$
 12  print i$

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
 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