Start: Nov, 12, 2017 10:00:00
2017秋Python程序设计基础培训第四次作业
End: Nov, 19, 2017 12:00:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 656ms
Memory: 24980kB
Author: shanzhenyu
In contest: 1124

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
for case in range(m):
    x,y = list(map(int, input().split()))
    i = a.index(y)
    a.insert(i,x)   

for n in a:
    print(n,end=" ")