U89852 Forever and always

题目背景

> 'Cause it seems to me. > > This thing is breaking down we almost never speak. > > I don't feel welcome anymore. > > Baby what happened. > > Please tell me.

题目描述

给定一个整数集合 $A = \{a_1,a_2,\cdots,a_n\}$。有 $m$ 次询问,每次询问给定一个整数 $k$,请判断方程 $\sum^{n}_{i = 1}a_i\times x_i = k$ 是否有非负整数解。

输入格式

第一行一个整数 $n$ ,代表集合 $A$ 的元素个数。 接下来一行 $n$ 个数表示 $a_i$。 接下来一个整数 $m$, 表示 $m$ 次询问。 接下来 $m$ 行,每行代表一个 $k$ 。

输出格式

输出 $m$ 行. 如果 $k$ 满足条件输出 `TAK`,否则输出 `NIE`。

说明/提示

样例解释: $0 = 0 * 2 + 0 * 5 + 0 * 7$ $4 = 2 * 2 + 0 * 5 + 0 * 7$ $12 = 0 * 2 + 1 * 5 + 1 * 7$ $2 = 1 * 2 + 0 * 5 + 0 * 7$ 对于所有数据,$1\le n\le 5\times 10^3$,$1\le m\le 10^4$,$1\le a_i\le 5\times 10^4$,$0\le k\le 10^9$。