Sums
Memory limit: 32 MB
We are given a set of positive integers
. Consider a set of
non-negative integers
, such that a number
belongs to
if and only if
is a sum of some elements from
(the elements may be repeated). For example, if
, then sample numbers belonging to the set
are: 0 (the sum of 0 elements), 2, 4
and 12
or
or
; and
the following do not belong to
: 1 and 3.
Task
Write a program which:
- reads from the standard input the description of the set
and
the sequence of numbers
,
- for each number
determines whether it belongs to the set
,
- writes the result to the standard output.
Input
In the first line there is one integer
: the number of elements of
the set
,
. The following
lines contain the elements of the set
, one per line.
In the
-st line there is one positive integer
,
.
,
.
In the
-nd line there is one integer
,
. Each of the following
lines contains one
integer in the range from
to
, they
are respectively the numbers
.
Output
The output should consist of
lines. The
-th line should
contain the word TAK ("yes" in Polish), if
belongs to
, and it should contain the word NIE
("no") otherwise.
Example
For the input data:
3
2
5
7
6
0
1
4
12
3
2
the correct result is:
TAK
NIE
TAK
TAK
NIE
TAK
Task author: Krzysztof Onak.