#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<bitset> usingnamespace std; //#define int long long typedeflonglong ll; #define MAXN 50006 #define pb push_back #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define inf 0x3f3f3f3f #define cmx( a , b ) a = max( a , b ) #define cmn( a , b ) a = min( a , b ) voidread( int& x ){ scanf("%d",&x); } voidread( ll& x ){ scanf("%lld",&x); } int n , q; int A[MAXN] , mx;
intmain(){ read( n ); for( int i = 1 ; i <= n ; ++ i ) read( A[i] ) , mx = max( mx , A[i] ); for( int i = 1 ; i <= n ; ++ i ) trans.set( A[i] ); for( int i = 0 ; i <= mx ; ++ i ) use.set( i ); bfs(); read( q ); int x; while( q --> 0 ) { read( x ); int a = x % mx , b = x / mx; puts( ( dis[a] == 0x3f3f3f3f || dis[a] > b ) ? "NIE" : "TAK" ); } }
/* * Things you should pay attention to * inf is big enough? * out of bounds? * long long ? */