#P8060. [POI 2003] Sums
[POI 2003] Sums
Problem Description
You are given a set of integers . Consider a set of non-negative integers . A number belongs to if and only if it can be represented as the sum of some elements from (elements may be used repeatedly).
For example, if , then numbers in include: (the sum of elements), , (), and ( or or ). However, and do not belong to .
Input Format
The first line contains an integer , the number of elements in set . Each of the next lines contains one integer , describing an element. .
Then an integer follows, and each of the next lines contains one integer, representing .
Output Format
Output lines. If belongs to , print TAK on the -th line; otherwise, print NIE.
3
2
5
7
6
0
1
4
12
3
2
TAK
NIE
TAK
TAK
NIE
TAK
Hint
For all testdata, , , , .
Translated by ChatGPT 5