You are given a set A of positive integers. Consider the set A′ of non-negative integers where a number x belongs to A′ if and only if x can be written as a sum of some elements of A (each element may be used any number of times, including zero times).
For example, if A={2,5,7}, then A′ contains 0 (the empty sum), 2, 4 (2+2) and 12 (5+7 or 2+2+2+2+2+2), while 1 and 3 do not belong to A′.
Given the description of the set A and a sequence of integers b1,b2,…,bk, write a program that decides, for each bi, whether it belongs to A′.
The first line contains the number of elements n of the set A (1≤n≤5000). Each of the next n lines contains one element of A: the (i+1)-th line holds a positive integer ai (1≤ai≤50000), with a1<a2<⋯<an, so that A={a1,a2,…,an}.
The (n+2)-th line contains the number of queries k (1≤k≤10000). Each of the next k lines contains one integer bi with 0≤bi≤109.
Print k lines. The i-th line must contain TAK (Polish for 'yes') if bi belongs to A′, and NIE (Polish for 'no') otherwise.