from sys import stdin, exit
solutions = [1,1,2,2,4,7,12,16,32]
covered, cover, N = [], [], 0
def add_to_cover(x):
cover.append(x)
number = len(cover)
if covered[x] == 0: covered[x] = number
for n in range(N):
if covered[ x ^ (2**n) ] == 0: covered[ x ^ (2**n) ] = number
def remove_from_cover(x):
number = len(cover)
cover.pop()
if covered[x]==number: covered[x] = 0
for n in range(N):
if covered[ x ^ (2**n) ] == number: covered[ x ^ (2**n) ] = 0
def go(x):
if len(cover) + (covered.count(0)+N)/(N+1) > solutions[N]: return
if x==2**N: exit()
if covered[x]>0:
go(x+1)
else:
add_to_cover(x) ; go(x+1) ; remove_from_cover(x)
for n in range(N):
other = x ^ (2**n)
add_to_cover(other) ; go(x+1) ; remove_from_cover(other)
def process_cover():
for n in range(N):
strategy = ''
for lo in range(2**n):
for hi in range(2**(N-1-n)):
with0 = (2*lo) * 2**(N-1-n) + hi
with1 = (2*lo+1) * 2**(N-1-n) + hi
guessed = False
if (with0 in cover) and not (with1 in cover): guessed, strategy = True, strategy + 'T'
if (with1 in cover) and not (with0 in cover): guessed, strategy = True, strategy + 'H'
if not guessed: strategy += 'P'
print strategy
for N in range(1,8):
covered, cover = [0]*(2**N), []
try: go(0)
except: pass
process_cover()
N = 8
cover2 = [2**7 + x for x in cover]
cover += cover2
process_cover()