Harryxun/stf_run huggingface dataset:
h,w,k=map(int,input().split())
dot=[list(input()) for i in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        
        count=0
        
        for ii in range(h):
            for jj in range(w):
                if(i >> ii)==0 & (j>>jj)==0:
                    if dot[i][j]=='#':
                        count+=1
    if count==k:
        ans+=1
print(ans)


### FIXED CODE ###

h,w,k=map(int,input().split())
dot=[list(input()) for i in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        
        count=0
        
        for ii in range(h):
            for jj in range(w):
                if(i >> ii)&1==0 and (j>>jj)&1==0:
                    if dot[ii][jj]=='#':
                        count+=1
        if count==k:
            ans+=1
print(ans)
N=int(input())
if N < 105:
    print(0)
elif 105 <= N and N < 135:
    print(1)
elif 135 <= N and N < 165:
    print(2)
elif 165 <= N and N < 189:
    print(3)
elif 189 <= N :
    print(4)

### FIXED CODE ###

A,B=(int(i) for i in input().split())
print(A*B-A-B+1)
n, q = [int(x) for x in input().split()]
vs   = []
xs   = []
	
for _ in range(0, n + 1):
	vs.append([])
	xs.append(0)

for _ in range(0, n - 1):
	a, b = [int(x) for x in input().split()]
	vs[a].append(b)

for _ in range(0, q):
	p, x   = [int(x) for x in input().split()]
	xs[p] += x
	
def calc(v, x, vs, xs):
	xs[v] += x
	for u in vs[v]:
		calc(u, xs[v], vs, xs)

calc(1, 0, vs, xs)

print(" ".join(str(x) for x in xs[1:]))


### FIXED CODE ###

n, q = [int(x) for x in input().split()]
vs   = []
	
for _ in range(0, n + 1):
	vs.append([])
	
xs    = [0]     * (n + 1)
fs    = [False] * (n + 1)
us    = [0]     * n
fs[1] = True
us[0] = 1
ui    = 0

for _ in range(0, n - 1):
	a, b = [int(x) for x in input().split()]
	vs[a].append(b)
	vs[b].append(a)

for _ in range(0, q):
	p, x   = [int(x) for x in input().split()]
	xs[p] += x
	
for i in range(0, n):
	x = xs[us[i]]
	for v in vs[us[i]]:
		if fs[v] == False:
			xs[v] += x
			ui    += 1
			us[ui] = v
			fs[v]  = True

print(" ".join(str(x) for x in xs[1:]))
n,m=map(int,input().split())
a=[list(input())for i in range(n)]
b=[list(input())for j in range(m)]
for i in range(m):
    for x in range(n-m):
        if a[i][x:x+m]==b[i]:
            flag=1
            for j in range(1,m):
                if a[i+j][x:x+m]!=b[i+j]:
                    flag=0
            if flag:
                print("Yes")
                exit()
print("No")
               

### FIXED CODE ###

n,m=map(int,input().split())
a=[list(input())for i in range(n)]
b=[list(input())for j in range(m)]
for i in range(n-m+1):
    for x in range(n-m+1):
        if a[i][x:x+m]==b[0]:
            flag=1
            for j in range(0,m):
                if a[i+j][x:x+m]!=b[j]:
                    flag=0
            if flag:
                print("Yes")
                exit()
print("No")
N = int(input())
L = [int(input()) for i in range(N)]
print("Yes" if max(L) < sum(L)-max(L) else "No")

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
print("Yes" if max(L) < sum(L)-max(L) else "No")
a_score, b_score = 0, 0
while(True):
  input_list = map(int, raw_input().split())
  if len(input_list) == 1 and input_list == 0:
    break
  elif len(input_list) == 1 and input_list != 0:
    if a_score != 0 or b_score != 0:
      print a_score, b_score
    a_score, b_score = 0, 0
  elif len(input_list) == 2:
    a, b = input_list
    if a > b:
      a_score += a + b
    elif b > a:
      b_score += a + b
    else:
      a_score += a
      b_score += b

### FIXED CODE ###


def solve():
  while(1):
    n = int(raw_input())
    if n == 0:
      break
    score_a, score_b = 0, 0
    while(n > 0):
      a, b = map(int, raw_input().split())
      if a > b:
        score_a += a + b
      elif b > a:
        score_b += a + b
      else:
        score_a += a
        score_b += b
      n -= 1
    print score_a, score_b

if __name__ == '__main__':
  solve()
# coding: utf-8
# Your code here!
target=input()
n = len(target)-1
bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
answer = 0

for bits in bit_list:
    one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
    # ここで1がある場所を取得
    start=0    
    # 街灯の箇所で文字を区切る関数を実装
    for index in one_number_indexes:
        answer=answer+int(target[start:index+1])
        start=index+1
    answer=answer+int(target[start:n+1])

print(answer)

### FIXED CODE ###

import itertools

target=input()
n = len(target)-1
#bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
status = [['0', '1'] for _ in range(n)]
bit_list = list(itertools.product(*status)) 


answer = 0

for bits in bit_list:
    one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
    
    # ここで1がある場所を取得
    start=0    
    # 街灯の箇所で文字を区切る関数を実装
    for index in one_number_indexes:
        answer=answer+int(target[start:index+1])
        start=index+1
    answer=answer+int(target[start:n+1])

print(answer)
from math import log2
import sys
n = int(input())
s =list(map(int, input().split()))
s.sort()
s.reverse()
flag = 0
if s[0] ==s[1]:
    print("No")
    sys.exit()
for i in range(2,2**n):
    ind = int(log2(i))
    if s[i-2**ind]==s[i]:
        flag =1
        break
if flag == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys
n = int(input())
s = list(map(int, sys.stdin.readline().split()))

s.sort()#popするのでreverseしない
#print(s)
P = [s[-1]]
P_next = []

Rem = s[:-1]
Rem_next = []
for _ in range(n):
    while P:
        p = P.pop()
        P_next.append(p)
        while Rem:
            r = Rem.pop()
            if p>r:
                P_next.append(r)
                break
            Rem_next.append(r)
        """
        while p == Rem[-1]:
            r = Rem.pop()
            Rem_next.append(r)
        if Rem:
            P_next.append(Rem.pop())
        """
    P = P_next
    P_next = []
    Rem += Rem_next
    Rem_next = []
    #不自然な置き換えに見えるがlistからremoveするよりはマシか
    P.sort()
    Rem.sort()
if len(P) == 2**n:
    print("Yes")
else:
    print("No")
num = int(sys.stdin.readline())
ans = num ** 3
print ans

### FIXED CODE ###

import sys
num = int(sys.stdin.readline())
ans = num ** 3
print ans
def f(n):
	a = ""
	while n>0:
		a += str(n%4)
		n //= 4
	return a[::-1]
	
while 1:
	n = input()
	if n == -1: break
	print f(n) if n > 0 else 0

### FIXED CODE ###

def f(n):
	a = ""
	while n>0:
		a += str(n%4)
		n //= 4
	return a[::-1]
	
while 1:
	n = input()
	if n == -1: break
	print f(n) if n > 0 else 0
#
# coding: utf-8
 
def bubbleSort(arr, n):
 
    flag = True
    swap_num = 0
 
    while flag:
        flag = False
        for j in xrange(n-1, 0, -1):
            if arr[j] < arr[j-1]:
                arr[j], arr[j-1] = arr[j-1], arr[j]
                swap_num += 1
                flag = True
        pass
    return swap_num
 
 
n = int(raw_input())
arr = map(int, raw_input().split())
 
num = bubbleSort(arr, n)
print " ".join(map(str, test_arr))
print num

### FIXED CODE ###

#
# coding: utf-8
 
def bubbleSort(arr, n):
 
    flag = True
    swap_num = 0
 
    while flag:
        flag = False
        for j in xrange(n-1, 0, -1):
            if arr[j] < arr[j-1]:
                arr[j], arr[j-1] = arr[j-1], arr[j]
                swap_num += 1
                flag = True
        pass
    return swap_num
 
 
n = int(raw_input())
arr = map(int, raw_input().split())
 
num = bubbleSort(arr, n)
print " ".join(map(str, arr))
print num
N, C = map(int, input().split())
stc = [list(map(lambda x:2*int(x), input().split())) for _ in range(N)]

stc = sorted(stc, key=lambda x:(x[2], x[0], x[1]))
l = []
i = N-1
s, t, c = 0, 0, 0
while i >= 0:
    if stc[i][2] == stc[i-1][2] and stc[i][0] == stc[i-1][1]:
        s = stc[i-1][0]
        if t == 0:
            t = stc[i][1]
        c = stc[i][2]
    else:
        if s != 0:
            l += [[s, t, c]]
            s, t, c = 0, 0, 0
        else:
            l += [stc[i]]

    i -= 1
        
imos = [0]*(10**5+1)
for s, t, c in l:
    imos[s-1] += 1
    imos[t] -= 1

for i in range(len(imos)-1):
    imos[i] = imos[i] + imos[i-1]

print(max(imos))





### FIXED CODE ###

N, C = map(int, input().split())
stc = [list(map(lambda x:int(x), input().split())) for _ in range(N)]

stc = sorted(stc, key=lambda x:(x[2], x[0], x[1]))
l = []
i = N-1
s, t, c = 0, 0, 0
while i >= 0:
    if stc[i][2] == stc[i-1][2] and stc[i][0] == stc[i-1][1]:
        s = stc[i-1][0]
        if t == 0:
            t = stc[i][1]
        c = stc[i][2]
    else:
        if s != 0:
            l += [[s, t, c]]
            s, t, c = 0, 0, 0
        else:
            l += [stc[i]]

    i -= 1
        
imos = [0]*(2*10**5+1)
for s, t, c in l:
    imos[s-1] += 1
    imos[t] -= 1

for i in range(len(imos)-1):
    imos[i] = imos[i] + imos[i-1]

print(max(imos))
l=int(input());b=bin(l)[2:];n=len(b);print(n,2*n+b.count("1")-3)
for i in range(1,n):print(i,i+1,0);print(i,i+1,1<<(i-1))if b[n-i]=="1":print(i,n,l);l-=1<<(i-1)

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    l = I()
    l = list(map(int,bin(l)[2:]))
    n = len(l)
    ans = []
    for i in range(n-1):
        ans.append((i+1,i+2,0))
        ans.append((i+1,i+2,1<<i))
    w = (1<<(n-1))
    for i in range(1,n):
        if l[i]:
            x = n-i
            ans.append((x,n,w))
            w += (1<<(x-1))
    print(n,len(ans))
    for x,y,w in ans:
        print(x,y,w)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()
s = input()
if s[0] = 7:
  print(Yes)
elif s[1] = 7:
  print(Yes)
elif s[2] = 7:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

s = str(input())
if s[0] is "7":
  print("Yes")
elif s[1] is "7":
  print("Yes")
elif s[2] is "7":
  print("Yes")
else:
  print("No")
x,y = int(input())
if x == y:
  print(-1)
else:
  for i in range(1,10000):
    a = i * x
    if a % y != 0:
      print(a)
      exit()

### FIXED CODE ###

x,y = map(int,input().split())
if x % y ==0:
  print(-1)
else:
  print(x)
A,B,C,X = input().split()
A = int(A)
B = int(B)
C = int(C)
X = int(X)

res = int(0)

for x in range(A+1):
	for y in range(B+1):
		for z in range(C+1):
			total = int(500*x + 100*y + 50*z)
			if(total == X):
				res+=1
			
print(res)

### FIXED CODE ###

A = input()
B = input()
C = input()
X = input()

A = int(A)
B = int(B)
C = int(C)
X = int(X)

res = int(0)

for x in range(A+1):
	for y in range(B+1):
		for z in range(C+1):
			total = int(500*x + 100*y + 50*z)
			if(total == X):
				res+=1
			
print(res)
_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = [[int(p) for p in i.split()] for i in _input[1:n]]

if not edge:
    print(k)
else:
    import collections
    import math

    all_edge_map = collections.defaultdict(list)
    for e in edge:
        all_edge_map[e[0]].append(e[1])
        all_edge_map[e[1]].append(e[0])

    if [for v in all_edge_map if len(all_edge_map[v]) >= k]:
        print(0)

    else:
        print('bad')


### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = tuple([tuple([int(p) for p in i.split()]) for i in _input[1:n]])

factorial = [0] * (k + 1)
inverse = [0] * (k + 1)
MOD = 1000000007

# Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/175024
def mod_pow1(n, k, mod):
    a = 1
    while k:
        if (k & 1) == 1:
            a = (a * n) % mod
        n = (n * n) % mod
        k >>= 1
    return a

# Ref: https://www.smartbowwow.com/2018/10/mod1097.html
def mod_pow2(n, k, mod):
    if k == 0:
        return 1
    if k % 2 == 0:
        a = mod_pow2(n, k // 2, mod)
        return (a * a) % mod
    else:
        return (n * mod_pow2(n, k - 1, mod)) % mod

#mod_pow = mod_pow1
# It's better to use built-in function for speed.
mod_pow = pow

def mod_factorial_inverse(k, mod):
    factorial[0] = 1
    inverse[0] = 1

    # Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
    for i in range(1, k + 1):
        factorial[i] = ((i * factorial[i - 1]) % mod) # factrial[i]
        inverse[i] = mod_pow(factorial[i], mod - 2, mod) # inverse[i]
 
total = 1

if not edge:
    print(k)
else:
    all_edge = tuple([[] for _ in range(n + 1)])
    for e in edge:
        all_edge[e[0]].append(e[1])
        all_edge[e[1]].append(e[0])
    all_edge = [set(v) for v in all_edge]

    if [v for v in all_edge if len(v) >= k]:
        print(0)
    else:
        mod_factorial_inverse(k, MOD)

        root = edge[0]
        total = (factorial[k] * inverse[k - len(all_edge[root[0]]) - 1]) % MOD

        def dfs(current, from_):
            global total
            child = all_edge[current]
            if len(child) - 1 > 0:
                total = (total * factorial[k - 2] * inverse[k - 2 - (len(child) - 1)]) % MOD
            for c in child:
                if c != from_:
                    dfs(c, current)
        for c in all_edge[root[0]]:
            dfs(c, root[0])
        print(total)
s=str(input())
s.raplace(","," ")
print(s)


### FIXED CODE ###

s = input()
ss = s.replace("," , " ")
print(ss)
import sys
import numpy as np


def main(stdin):
    N, K, Q = stdin[:3]
    ans = np.full(N + 1, K - Q, dtype=np.int64)
    for i in stdin[3:]:
        ans[i] += 1
    ans = np.where(ans > 0, 'Yes', 'No')
    return ans[1:]


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[:],)')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    stdin = np.array([int(_) for _ in open(0).read().split()])
    print(*main(stdin), sep='\n')


### FIXED CODE ###

N, K, Q = [int(_) for _ in input().split()]
A = [int(input()) for _ in range(Q)]
s = [K - Q] * (N + 1)
for a in A:
    s[a] += 1
for i in range(1, N + 1):
    if s[i] > 0:
        print('Yes')
    else:
        print('No')
N=int(input())
S=input()

def solve(n,str):
  if n==N:
    if str[-2]==str[0] and str[-1]==str[1]:
      str=str[1:-1]
    else:
      str=""
    return str
  else:
    if (S[n]=="o" and str[-1]=="S") or (S[n]=="x" and str[-1]=="W"):
      str=str+str[-2]
    else:
      if str[-2]=="W":
        str=str+"S"
      else:
        str=str+"W"
    ans=solve(n+1,str)
    return ans

flgT=["SSS","SWW","WWS","WSW"]
flgF=["SSW","WSS","SWS","WWW"]
imp=True
if S[0]=='o':
  for i in range(4):
    ans=solve(1,flgT[i])
    if len(ans)>0:
      print(ans)
      imp=False
      break
else:
  for i in range(4):
    ans=solve(1,flgF[i])
    if len(ans)>0:
      print(ans)
      imp=False
      break
if imp:
  print(-1)

### FIXED CODE ###

import sys

N=int(input())
S=input()

flgT=["SSS","SWW","WWS","WSW"]
flgF=["SSW","WSS","SWS","WWW"]

if S[0]=='o':
  for i in range(4):
    str=flgT[i]
    for j in range(1,N):
      if (S[j]=="o" and str[-1]=="S") or (S[j]=="x" and str[-1]=="W"):
        str=str+str[-2]
      else:
        if str[-2]=="W":
          str=str+"S"
        else:
          str=str+"W"
    if str[-2]==str[0] and str[-1]==str[1]:
      str=str[1:-1]
      print(str)
      sys.exit()
else:
  for i in range(4):
    str=flgF[i]
    for j in range(1,N):
      if (S[j]=="o" and str[-1]=="S") or (S[j]=="x" and str[-1]=="W"):
        str=str+str[-2]
      else:
        if str[-2]=="W":
          str=str+"S"
        else:
          str=str+"W"
    if str[-2]==str[0] and str[-1]==str[1]:
      str=str[1:-1]
      print(str)
      sys.exit()

print(-1)
K,N = map(int,input().split())
A = list(map(int,input().split()))

foK,N = map(int,input().split())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
  now = i
  pre = now-1
  post = now +1
  #nowとpreの距離を求める
  if now == 0:
    preDic = (K-A[N-1])+A[now]
  else:
    preDic = A[now]-A[pre]
  postDic = A[post]-A[now]  
  if preDic >= postDic:#時計回りに、i-1の位置まで進む
    ans.append(K-preDic)
  else:
    ans.append(K-postDic)

    
print(min(ans))

### FIXED CODE ###

K,N = map(int,input().split())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
  now = i
  pre = now-1
  post = now +1
  #nowとpreの距離を求める
  if now == 0:
    preDic = (K-A[N-1])+A[now]
  else:
    preDic = A[now]-A[pre]
  postDic = A[post]-A[now]  
  if preDic >= postDic:#時計回りに、i-1の位置まで進む
    ans.append(K-preDic)
  else:
    ans.append(K-postDic)
  
print(min(ans))
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        return 2
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            return f
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
        return n
    return n

A_B = prime_factorize(X)
A = 1
while True:
    if X % A == 0:
        print(A, A - A_B)
        return
    A += 1

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

for a in range(2000):
    A = a - 1000

    for b in range(2000):
        B = b - 1000
        if A ** 5 - B ** 5 == X:
            print("{} {}".format(A, B))
            exit()
n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k]:
		ss += s[i]
	else:
		ss += '*'
print(ss)

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k-1]:
		ss += s[i]
	else:
		ss += '*'
print(ss)
m = int(input())
n = int(input())

x = max(m, n)
y = min(m, n)
if x % y == 0:
  print(x)
else:
  while x%y!=0:
    z = x % y
    x = y
    y = z
  else:
    print(int(m * n / z))

### FIXED CODE ###

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

a =  (input().split())
b = [1, 1]
b[0] = int(a[0])
b[1] = int(a[1])
print(lcm(b))
N M =map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")
n=int(input())
a=map(int,input().split())
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            print("DENIED")
            exit()
print("APPROVED")


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            print("DENIED")
            exit()
print("APPROVED")
S=input()
alphabet=[chr(i) for i in range(ord('a'),ord('z')+1)]
if len(S)!=26:
    for x in alphabet: 
        if not(x in set(S)):
            flag=1
            break
    ans=S+x
    print(ans)
else:
    s=ord(S[25])
    for i in range(24,-1,-1):
        if s<ord(S[i]):
            j=i
            s=ord(S[i])

    if j==0:
        print(-1)
    else:
        l=S[j:]
        y=300
        for x in list(map(ord,l)):
            if ord(S[j-1])<x:
                y=min(y,x)
        ans=S[:j-1]+chr(y)
        print(ans)

### FIXED CODE ###

S=input()
alphabet=[chr(i) for i in range(ord('a'),ord('z')+1)]
if len(S)!=26:
    for x in alphabet: 
        if not(x in set(S)):
            flag=1
            break
    ans=S+x
    print(ans)
else:
    s=ord(S[25])
    j=25
    for i in range(24,-1,-1):
        if s<ord(S[i]):
            j=i
            s=ord(S[i])
        else:
            break

    if j==0:
        print(-1)
    else:
        l=S[j:]
        y=300
        for x in list(map(ord,l)):
            if ord(S[j-1])<x:
                y=min(y,x)
        ans=S[:j-1]+chr(y)
        print(ans)
yy,dd,mm =map(int,input().split('/'))
    x = 0
    if(yy<=2019):
      if(mm<=4):
        if(dd<=30):
         x = 1
     
    if(x == 1):
      print('Heisei')
    else:
      print('TBD')
        
      

### FIXED CODE ###

yy,mm,dd =map(int,input().split('/'))
x = 0
if(yy<=2019):
  if(mm<=4):
    if(dd<=30):
      x = 1
         
if(x == 1):
  print('Heisei')
else:
  print('TBD')