A dispatcher has n item codes to sort and a priority reference list of m distinct codes. Every item code that appears in the reference list must be ordered according to its position in that list (earlier in the reference list means earlier in the output). Duplicate copies of the same code stay together. Every item code that does NOT appear in the reference list goes after all the referenced ones, ordered by ascending value.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the item codes to sort.
Line 3: an integer m.
Line 4: m space-separated distinct integers, the priority reference list.
Output format
n space-separated integers on one line: the item codes in the described order.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ m ≤ 100000
- codes and reference values fit in a 32-bit signed integer; reference values are distinct.