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: 1340ms
Memory: 24992kB
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()))
    for i in range(len(a)):
        if a[i] == y:
            break;
    a.insert(i,x)   

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