from sys import stdin
from collections import Counter
stdin.readline()
counter = Counter(stdin.readline().strip().split())
stdin.readline()
for val in stdin.readline().strip().split():
if val not in counter:
print("brak")
continue
if counter.get(val) >= 3:
print("Tak")
continue
print("Nie")
ZnJvbSBzeXMgaW1wb3J0IHN0ZGluCmZyb20gY29sbGVjdGlvbnMgaW1wb3J0IENvdW50ZXIKCnN0ZGluLnJlYWRsaW5lKCkKCmNvdW50ZXIgPSBDb3VudGVyKHN0ZGluLnJlYWRsaW5lKCkuc3RyaXAoKS5zcGxpdCgpKQoKc3RkaW4ucmVhZGxpbmUoKQoKZm9yIHZhbCBpbiBzdGRpbi5yZWFkbGluZSgpLnN0cmlwKCkuc3BsaXQoKToKCWlmIHZhbCBub3QgaW4gY291bnRlcjoKCQlwcmludCgiYnJhayIpCgkJY29udGludWUKCQoJaWYgY291bnRlci5nZXQodmFsKSA+PSAzOgoJCXByaW50KCJUYWsiKQoJCWNvbnRpbnVlCgkKCXByaW50KCJOaWUiKQo=