fork download
  1. import io, os, sys
  2. input=(io.BytesIO(os.read(0, os.fstat(0).st_size)).readline)
  3. nt=int(input())
  4. nin=[]
  5. notp=set()
  6. pld=set()
  7. notp={'0','2','4','5','6','8'}
  8. pld={'1','3','7','9'}
  9.  
  10. for it in range(nt):
  11. nin.append(int(input()))
  12.  
  13. for n in nin:
  14. ans=''
  15. if n>5 and str(n)[-1] in notp:
  16. ans='NIE\n'
  17. elif n>10 and str(n)[-1] not in pld:
  18. ans='NIE\n'
  19. elif n<=9:
  20. if n==1 or n==4 or n==9:
  21. ans='NIE\n'
  22. else:
  23. ans='TAK\n'
  24.  
  25. if ans=='':
  26. ans='TAK\n'
  27. for i in range (3, int(n**0.5)+1):
  28. if n%i==0:
  29. ans='NIE\n'
  30. break
  31.  
  32. sys.stdout.write(ans)
Success #stdin #stdout 0.05s 65164KB
stdin
2
111
123456919
stdout
NIE
TAK