HZNUOJ


Problem_ID: G
Result: Accepted
Time: 427ms
Memory: 26096kB
Author: 13758696008
In contest: 1300

n,m=map(int,input().split())
lst=input().split()
for i in range(m):
    a=input().split()
    j=lst.index(a[1])
    lst.insert(j,a[0])
for w in lst:
    print(w,end=" ")