Sums

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given a set AA of positive integers. Consider the set AA' of non-negative integers where a number xx belongs to AA' if and only if xx can be written as a sum of some elements of AA (each element may be used any number of times, including zero times).

For example, if A={2,5,7}A = \{2, 5, 7\}, then AA' contains 00 (the empty sum), 22, 44 (2+22+2) and 1212 (5+75+7 or 2+2+2+2+2+22+2+2+2+2+2), while 11 and 33 do not belong to AA'.

Given the description of the set AA and a sequence of integers b1,b2,,bkb_1, b_2, \dots, b_k, write a program that decides, for each bib_i, whether it belongs to AA'.

Input

The first line contains the number of elements nn of the set AA (1n50001 \le n \le 5000). Each of the next nn lines contains one element of AA: the (i+1)(i+1)-th line holds a positive integer aia_i (1ai500001 \le a_i \le 50000), with a1<a2<<ana_1 < a_2 < \dots < a_n, so that A={a1,a2,,an}A = \{a_1, a_2, \dots, a_n\}.

The (n+2)(n+2)-th line contains the number of queries kk (1k100001 \le k \le 10000). Each of the next kk lines contains one integer bib_i with 0bi1090 \le b_i \le 10^9.

Output

Print kk lines. The ii-th line must contain TAK (Polish for 'yes') if bib_i belongs to AA', and NIE (Polish for 'no') otherwise.