1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long lolo;
typedef vector< lolo > vlolo;

template < typename T >
istream& operator>> ( istream&, vector< T >& ); 

vlolo make_fibo ( lolo rmax )
{
	vlolo fib = { 0, 1 };
	int i = fib.size() - 1;
	while( fib[i] < rmax ) {
		fib.push_back( fib[i-1] + fib[i] );
		i++;
	}
	return fib;
}

vlolo mulify( vlolo const& vec )
{
	vlolo result;
	for ( auto e1 : vec ) {
		for ( auto e2 : vec ) {
			result.push_back( e1 * e2 );
		}
	}
	auto it = unique( result.begin(), result.end() );
	vlolo( result.begin(), it ).swap( result );
	return result;
}

void write_results( vlolo const& search_for, vlolo const& search_in ) 
{
	auto it = search_in.begin();
	auto et = search_in.end();
	for ( auto el : search_for ) {
		cout << ( (find( it, et, el ) == et) ? "NIE" : "TAK" ) << endl; 
	}

}

int main()
{
	vlolo iloczyny;
	cin >> iloczyny;

	vlolo fib = make_fibo( * max_element( iloczyny.begin(), iloczyny.end()) );
	vlolo bif = mulify( fib );
	write_results( iloczyny, bif );
}


template< typename T >
istream& operator>> ( istream& is, vector< T >& v )
{
	int n; is >> n;
	v.resize( n );
	for( int i = 0; i < n; ++i ) {
		is >> v[i];
	}
	return is;
}