HZNUOJ


Problem_ID: G
Result: Accepted
Time: 439ms
Memory: 26096kB
Author: 13666776648
In contest: 1300

n,t=map(int,input().split())
s=input().split()

for i in range(t):
    a=input().split()
    s.insert(s.index(a[1]),a[0])

for i in s:
    print(i,end=" ")
print()