WILLITST - Will it ever stop

When Bob was in library in University of Warsaw he saw on one of facades caption :"Will it ever stop?" and below some mysterious code:

while n > 1
  if n mod 2 = 0 then
    n:=n/2
  else
    n:=3*n+3

Help him finding it out !

Input

In first line one number n<=10^14.

Output

Print "TAK" if program will stop, otherwise print "NIE"

Example

Input:
4

Output:
TAK

Added by:Krzysztof Lewko
Date:2011-11-09
Time limit:0.906s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:AMPPZ 2011

hide comments
2016-07-31 07:48:01
AC in one go!!
2016-07-25 13:05:19
AC in one go,Easy af ;)
2016-07-02 20:59:35
https://en.wikipedia.org/wiki/Collatz_conjecture
2016-06-17 19:17:27
Was printing TAE instead of TAK... got me 2 WA lol....
2016-06-14 19:19:43 suraj
can't get O(1) solution,help me
2016-06-12 07:38:34
collatz conjecture-all u need to know
2016-06-11 19:06:13
dont use float or double it gives WA , in some testcases. can't figure out why
sol in O(1)
2016-05-21 18:31:17
It is a slight modified form of collatz conjecture, but this problem illustrates that how a slight modification can solve a problem so easily.
2016-01-29 17:42:46
O(1) solution, check if n <= 1 || n & (n-1) == 0
2016-01-19 19:10:43 Bijoy Rahman Arif
WC: O(log2(n)) : this is the best solution I guess.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.