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
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include <cstdio>
#include <vector>


using namespace std;




void GenerateFib(unsigned long long int *fib, int size)
{
	fib[0]=1;
	fib[1]=2;

	for(int i=2;i<size;++i)
	{
		fib[i]=fib[i-1]+fib[i-2];
	}
}

void GenerateAllFib(vector<unsigned long long int> &all_fib, unsigned long long int *fib, int size)
{
	all_fib.clear();
	
	all_fib.push_back(0);
	all_fib.push_back(1);
	for(int j=0;j<size;++j)
	{
		for(int i=j;i<size;++i)
		{
			unsigned long long int ij=fib[i]*fib[j];
			if(ij<=1000*1000*1000)
			{
				all_fib.push_back(ij);
			}
		}
	}
}

void checkFib(vector<unsigned long long int> all_fib, unsigned long long int a)
{
	for(int i=0;i<all_fib.size();++i)
	{
		if(a==all_fib[i])
		{
			printf("TAK\n");
			return;
		}
	}
	printf("NIE\n");
}

int main()
{
	int fib_size=48;
	unsigned long long int *fib=new unsigned long long int[fib_size];
	
	GenerateFib(fib,fib_size);
	/*
	for(int i=0;i<fib_size;++i)
	{
#ifdef _MSC_VER
		printf("%d -> %I64d   %lf\n",i,fib[i],fib[i]/1000000000.0);
#else
		printf("%d -> %lld   %lf\n",i,fib[i],fib[i]/1000000000.0);
#endif
	}
	*/

	
	vector<unsigned long long int> all_fib;
	GenerateAllFib(all_fib,fib,fib_size);

	/*printf("all_fib.size=%d\n",all_fib.size());

	for(int i=0;i<all_fib.size();++i)
	{
#ifdef _MSC_VER
		printf("%d  %I64d\n",i,all_fib[i]);
#else
		printf("%d  %lld\n",i,all_fib[i]);
#endif
	}*/



	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;++i)
	{
		unsigned long long int a;
#ifdef _MSC_VER
		scanf("%I64d",&a);
#else
		scanf("%lld",&a);
#endif

		checkFib(all_fib,a);
	}
	

	delete[] fib;
}