# URL :- https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/memorise-me/

from collections import Counter

arrlen = int(input())
myinput = Counter(input().split())

qlen = int(input())
q = []
for i in range(qlen):
    myip = input()
    count = myinput.get(myip,"NOT PRESENT")
    q.append(count)
print(*q, sep="\n")

dd99127e8b5581521535fee8df87e59b8d717cf3
<mask token>

<mask token>
for i in range(qlen):
    myip = input()
    count = myinput.get(myip, 'NOT PRESENT')
    q.append(count)
print(*q, sep='\n')

<mask token>
arrlen = int(input())
myinput = Counter(input().split())
qlen = int(input())
q = []
for i in range(qlen):
    myip = input()
    count = myinput.get(myip, 'NOT PRESENT')
    q.append(count)
print(*q, sep='\n')

from collections import Counter
arrlen = int(input())
myinput = Counter(input().split())
qlen = int(input())
q = []
for i in range(qlen):
    myip = input()
    count = myinput.get(myip, 'NOT PRESENT')
    q.append(count)
print(*q, sep='\n')

# URL :- https://www.hackerearth.com/practice/data-structures/arrays/1-d/practice-problems/algorithm/memorise-me/

from collections import Counter

arrlen = int(input())
myinput = Counter(input().split())

qlen = int(input())
q = []
for i in range(qlen):
    myip = input()
    count = myinput.get(myip,"NOT PRESENT")
    q.append(count)
print(*q, sep="\n")
