HZNUOJ


Problem_ID: G
Result: Accepted
Time: 389ms
Memory: 25868kB
Author: 2018212212087
In contest: 1300

n,t=map(int,input().split())
id=list(map(int,input().split()))
for i in range(t):
	x,y=map(int,input().split())
	id.insert((id.index(y)),x)
for i in id:
	print(i,end=" ")