Chef Watson uses a social network called ChefBook, which has a new feed consisting of posts by his friends. Each post can be characterized by f - the identifier of the friend who created the post, p - the popularity of the post(which is pre-calculated by ChefBook platform using some machine learning algorithm) and s - the contents of the post which is a string of lower and uppercase English alphabets.
Also, Chef has some friends, which he has marked as special.
The algorithm used by ChefBook for determining the order of posts in news feed is as follows:

- Posts of special friends should be shown first, irrespective of popularity. Among all such posts the popular ones should be shown earlier.
- Among all other posts, popular posts should be shown earlier.

Given, a list of identifiers of Chef's special friends and a list of posts, you have to implement this algorithm for engineers of ChefBook and output the correct ordering of posts in the new feed. 

-----Input-----
First line contains N, number of special friends of Chef and M, the number of posts. Next line contains N integers A1, A2, ..., AN denoting the identifiers of special friends of Chef. Each of the next M lines contains a pair of integers and a string denoting f, p and s, identifier of the friend who created the post, the popularity of the post and the contents of the post, respectively. It is guaranteed that no two posts have same popularity, but the same friend might make multiple posts.

-----Output-----
Output correct ordering of posts in news feed in M lines. Output only the contents of a post.

-----Constraints-----
- 1 ≤ N, M ≤ 103
- 1 ≤ Ai, f, p ≤  105
- 1 ≤ length(s) ≤  100

-----Example-----
Input:
2 4
1 2
1 1 WhoDoesntLoveChefBook
2 2 WinterIsComing
3 10 TheseViolentDelightsHaveViolentEnds
4 3 ComeAtTheKingBestNotMiss

Output:
WinterIsComing
WhoDoesntLoveChefBook
TheseViolentDelightsHaveViolentEnds
ComeAtTheKingBestNotMiss

-----Explanation-----

First we should show posts created by friends with identifiers 1 and 2. Among the posts by these friends, the one with more popularity should be shown first.

Among remaining posts, we show those which are more popular first.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'n,m=list(map(int,input().split()))\nl=list(map(int,input().split()))\nl.sort()\nl2=[]\nl4=[]\nl5=[]\nl6=[]\nl7=[]\nfor i in range(m):\n l3=input().split()\n l3[0]=int(l3[0])\n l3[1]=int(l3[1])\n l2.append(l3)\n\nfor k in range(len(l2)):\n if l2[k][0] in l:\n  l4.append(k)\n  l6.append(l2[k][1])\n else:\n  l5.append(k)\n  l7.append(l2[k][1])\n\nwhile True:\n max=0\n c=0\n for i in range(len(l6)):\n  if l6[i]>max:\n   max=l6[i]\n   c=i\n if max==0:\n  break\n y=int(l4[c])\n print(l2[y][2])\n l6[c]=0\n \nwhile True:\n max=0\n c=0\n for i in range(len(l7)):\n  if l7[i]>max:\n   max=l7[i]\n   c=i\n if max==0:\n  break\n y=int(l5[c])\n print(l2[y][2])\n l7[c]=0\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13897