X Olympiad in Informatics 2002/2003
|
Problem: Sums
|
Author: Krzysztof Onak
|
We are given a set of positive integers A. Consider a set of non-negative integers A', such that a number x belongs to A' if and only if x is a sum of some elements from A (the elements may be repeated). For example, if A = {2,5,7}, then sample numbers belonging to the set A' are: 0 (the sum of 0 elements), 2, 4 (2 + 2) and 12 (5 + 7 or 7 + 5 or 2 + 2 + 2 + 2 + 2 + 2); and the following do not belong to A': 1 and 3.
In the (n + 2)-nd line there is one integer k, 1 <= k <= 10000. Each of the following k lines contains one integer in the range from 0 to 1000000000, they are respectively the numbers b1, b2, ..., bk.
3 2 5 7 6 0 1 4 12 3 2the correct answer is in the following output:
TAK NIE TAK TAK NIE TAK