Harryxun/stf_run huggingface dataset:
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す

black_count=0
for i in range(h):
    black_count+=c[i].count("#")

print(h*w-black_count-search())#全体からもともと黒の#の数と通った白い道を削除


### FIXED CODE ###

from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す
    return -1
black_count=0
for i in range(h):
    black_count+=c[i].count("#")
path=search()#通る道
if path==-1:
    print(path)
else:
    print(h*w-black_count-path)#全体からもともと黒の#の数と通った白い道を削除
X,Y,Z,K = list(map(int,input().split()))

A = sorted(list(map(int,input().split())))
A.reverse()
B = sorted(list(map(int,input().split())))
B.reverse()
C = sorted(list(map(int,input().split())))
C.reverse()

ia,ib,ic = 0,0,0
_min_ = 10000000000001
for ida,a in enumerate(A) :
    for idb,b in enumerate(B[:int(K/ida)]):
        idc = int(K/(ida+1)/(idb+1)) -1
        if  idc < len(C) and a+b+C[idc] < _min_:
            _min_ = a+b+C[idc]
            ia,ib,ic = ida,idb,idc

import itertools
#print(list(itertools.product(A[:s_a], B[:s_b],C[:s_c])))
for idx,value in enumerate(sorted([sum(i) for i in  list(itertools.product(A[:ia], B[:ib],C[:ic]))])[::-1]):
    if idx > K-1:
        break
    print(value)



### FIXED CODE ###

X,Y,Z,K = list(map(int,input().split()))
A = [(sorted(list(map(int,input().split())))[::-1]) for i in range(3)]
b = sorted([i+j for i in A[0] for j in A[1]])[-K:]
for i in sorted([i+j for i in b for j in A[2]])[-K:][::-1] :
  print(i)
import math
a, b, x = map(int, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))


### FIXED CODE ###

import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N, C):
    last = [-1] * N
    pairs = []
    for i, c in enumerate(C):
        prev = last[c - 1]
        if prev >= 0 and prev < i - 1:
            pairs.append((prev, i))
        last[c - 1] = i
    print(0)
    pairs.sort()
    count = [0] * N
    count[0] = 1
    idx = 0
    for i in range(N):
        if i > 0:
            count[i] += count[i - 1]
            count[i] %= MOD
        while idx < len(pairs) and pairs[idx][0] == i:
            count[pairs[idx][1]] += count[i]
            count[pairs[idx][1]] %= MOD
            idx += 1
    print(count[N - 1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
MAX_N = 200000

def solve(N, C):
    last = [-1] * MAX_N
    pairs = []
    for i, c in enumerate(C):
        try:
            prev = last[c - 1]
        except:
            if c >= N:
                return
            else:
                raise Exception()
        if prev >= 0 and prev < i - 1:
            pairs.append((prev, i))
        last[c - 1] = i
    pairs.sort()
    count = [0] * N
    count[0] = 1
    idx = 0
    for i in range(N):
        if i > 0:
            count[i] += count[i - 1]
            count[i] %= MOD
        while idx < len(pairs) and pairs[idx][0] == i:
            count[pairs[idx][1]] += count[i]
            count[pairs[idx][1]] %= MOD
            idx += 1
    print(count[N - 1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, C)

if __name__ == '__main__':
    main()
# 0〜9
l=list(range(10))

# 入力
N,K=map(str,input().split())
l2=list(map(int,input().split()))

ans=''
f=False

# 使用可能な数字を求める
for x in l2:
  l.remove(x)

# Nと桁数が一致する場合
if int(N[0])<l[-1]:
  for i in range(len(N)):
    for x in l:
      if f:
        ans+=str(x)
        break
      elif int(N[i])<x:
        f=True
        ans+=str(x)
        break
      elif int(N[i])==x:
        ans+=str(x)
        break
# Nと桁数が一致する可能性がある場合
elif int(N[0])==l[-1]:
  l3=list(N[1:])
  l3=list(map(int,set(l3)))
  l3.sort()

  # Nと桁数が一致しない
  if l3[-1]>l[-1]:
    # 最上位は0以外の最小の数にする
    if l[0]==0:
      ans+=str(l[1])
      ans+='0'*len(N)
    else:
      ans+=str(l[0])*(len(N)+1)

  # Nと桁数が一致する
  else:
    for i in range(len(N)):
      for x in l:
        if f:
          ans+=str(x)
          break
        elif int(N[i])<x:
          f=True
          ans+=str(x)
          break
        elif int(N[i])==x:
          ans+=str(x)
          break

# Nと桁数が一致しない場合
else:
  # 最上位は0以外の最小の数にする
  if l[0]==0:
    ans+=str(l[1])
    ans+='0'*len(N)
  else:
    ans+=str(l[0])*(len(N)+1)

# 出力
print(ans)

### FIXED CODE ###

l=[str(x) for x in range(100000)]
n,k=map(int,input().split())
l2=list(map(str,input().split()))
ind=l.index(str(n))
while True:
  a=l[ind]
  f=False
  for x in l2:
    if x in a:
      f=True
  if not f:
    break
  ind+=1
print(a)
V=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','y','z']
ch = input()
for i in range(26):
  if(ch==V[i]):
    print(V[i+1])


### FIXED CODE ###

V=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','y','z']
ch = input()
for i in range(25):
  if(ch==V[i]):
    print(V[i+1])
# import sys
# sys.setrecursionlimit(2147483647)

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


vertice = [-1 for _ in range(n)]
stack = [(0, 0)]

while stack:
    parent, vertex = stack.pop()
    vertice[vertex] = vertice[parent] * (-1)
    for next in edges[vertex]:
        if next != parent:
            stack.append((vertex, next))

# vertice = [0 for _ in range(n)]
#
#
# def dfs(v, color_i):
#     vertice[v] = color_i
#     for i in edges[v]:
#         if vertice[i] == 0:
#             dfs(i, color_i*(-1))
#
# dfs(0, 1)

ans = []
if vertice.count(1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num3:
                ans.append(str(num3.pop()))
                continue
        ans.append(str(not3.pop()))
elif vertice.count(-1) <= n // 3:
    not3 = [i for i in range(1, n+1) if i % 3 != 0]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == -1:
            if num3:
                ans.append(str(num3.pop()))
                continue
        ans.append(str(not3.pop()))
else:
    num1 = [i for i in range(1, n+1) if i % 3 == 1]
    num2 = [i for i in range(1, n+1) if i % 3 == 2]
    num3 = [i for i in range(1, n+1) if i % 3 == 0]
    for v in vertice:
        if v == 1:
            if num1:
                ans.append(str(num1.pop()))
            else:
                ans.append(str(num3.pop()))
        else:
            if num2:
                ans.append(str(num2.pop()))
            else:
                ans.append(str(num3.pop()))

print(" ".join(ans))


### FIXED CODE ###

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
 
group = [False] * n
parent = list(range(n))
stack = [0]
while stack:
  v = stack.pop()
  while edge[v]:
    u = edge[v].pop()
    if parent[v] != u:
      group[u] = not group[v]
      parent[u] = v
      stack.append(u)
 
three = 3
p = [0] * n
if group.count(False) <= n // 3:
  other = 1
  for i in range(n):
    if group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
elif group.count(True) <= n // 3:
  other = 1
  for i in range(n):
    if not group[i] and other <= n:
      p[i] = other
      other += other % 3
    else:
      p[i] = three
      three += 3
else:
  one, two = 1, 2
  for i in range(n):
    if group[i] and one <= n:
      p[i] = one
      one += 3
    elif not group[i] and two <= n:
      p[i] = two
      two += 3
    else:
      p[i] = three
      three += 3
print(' '.join(map(str, p)))
input_num = input()
input_list = input()

total_pow = 1
[total_pow*=int(num) for num in input_list.split(" ")]

if total_pow > 10**18:
  print("-1")
else:
  print(total_pow)

### FIXED CODE ###

import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)
N = int(input())
a = [input() for i in range(N)]

for num in range(1, N+1):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')

### FIXED CODE ###

N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')
import math
a,b=map(int,input().split())
print(a*b/gcd(a,b))

### FIXED CODE ###

import math
a,b=map(int,input().split())
x,y=a,b
while b!=0:
  a,b=b,a%b
print(x*y//a)
a,b = map(int, input().split())
d = b - a
bh = 0
for i in range(n+1):
  bh += bh + i
print(bh - b)

### FIXED CODE ###

a,b = map(int, input().split())
bh = 0
for i in range(b-a+1):
  bh += i
print(bh-b)
3 20

### FIXED CODE ###

x,y=map(int,input().split())
i=1
while x*2<=y:
  i+=1
  x*=2
print(i)
n,x= int(input().split())
b_list= list(map(int, input().split()))
temp = 0
counter = 0
for i in b_list:
    if (temp<=x):
        counter +=1
    temp += i

print(counter)


### FIXED CODE ###

n,x= input().split()
b_list= list(map(int, input().split()))
temp = 0
counter = 1
for i in range(int(n)):
    temp += b_list[i]
    if (temp<=int(x)):
        counter +=1
    else:
        break

print(counter)
import math

a,b,k = map(int,input().split())
x = math.gcd(a,b)
list_num = []
for i in range(1,x+1):
    if x % i == 0:
        list_num.append(i)
list_num = sorted(list_num,reverse=True)
print(list_num[k-1])

### FIXED CODE ###

def gcd(a,b):
    if b==0: 
        return a
    return gcd(b,a%b)

a,b,k = map(int,input().split())
x = gcd(a,b)
list_num = []
for i in range(1,x+1):
    if x % i == 0:
        list_num.append(i)
list_num = sorted(list_num,reverse=True)
print(list_num[k-1])
# ########## ------ Import ------- ##########

import sys
import math
from collections import Counter
from collections import deque as deq
from functools import lru_cache

# ########## ------ Define -------- #########

INT_MAX = float("inf")
INT_MIN = float("-inf")

# ########## ------ Input Functions ---- #########

input = sys.stdin.readline


def inp():
    return(int(input()))


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


def insr():
    s = input()
    return(list(s[:len(s) - 1]))


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


# ########## ------ Code ------- ##########
def go(i):
    if i == 0:
        dp[i] = 0
        return 0
    if i == 1:
        dp[i] = abs(a[0] - a[i])
        return dp[i]

    if dp[i] != -1:
        return dp[i]

    dp[i] = min(abs(a[i] - a[i - 1]) + go(i - 1),
                abs(a[i] - a[i - 2]) + go(i - 2))
    return dp[i]


t = inp()
a = inlt()
dp = [-1] * (t + 1)
print(go(t - 1))



### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(arr[1] - arr[0])

for i in range(1, n - 1):
    dp[i + 1] = min(dp[i - 1] + abs(arr[i + 1] - arr[i - 1]), dp[i] + abs(arr[i + 1] - arr[i]))

print(dp[-1])
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0

for i in range(len(L)-2):
  for j in range(i+1, len(L)-1):
    k = j + 1
    while L[k-1] == L[k]:
      k += 1
    cnt += bisect_left(L,L[i]+L[j]) - k

print(cnt)


### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    cnt += max(bisect_left(L, L[i]+L[j]) - (j+1), 0)

print(cnt)
#!C:\Users\daichi\Anaconda3/python.exe
# -*- coding: utf-8 -*-

C = input().split()
a = C[0]
b = C[1]
c = C[1]

if(a == b and a == c):
    k = 3
if(a == c and a != b):
    k = 2 
if(a != b and c != b):
    k = 1

print(k)

### FIXED CODE ###

#!C:\Users\daichi\Anaconda3/python.exe
# -*- coding: utf-8 -*-

C = input().split()
a = C[0]
b = C[1]
c = C[2]

k=3
if(a == b and b == c):
    k = 1
elif(a == b and b != c):
    k = 2
elif(a == c and b != c):
    k = 2
elif(b == c and a != c):
    k = 2
else:
    k=3
print(k)
import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


# A
def A():


# B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        if i >= k:
            ans += 1
    print(ans)


# C
def C():


# D
def D():


# E
def E():


# F
def F():


# Solve
if __name__ == "__main__":
    B()


### FIXED CODE ###

import sys


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


sys.setrecursionlimit(1000000)
mod = 1000000007


# A
def A():
    return


# B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        if i >= k:
            ans += 1
    print(ans)
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    B()
n = int(input())
h = list(map(int, input().split()))

import numpy as np

d = [0] * n

d[1] = np.abs(h[1] - h[0])

for i in range(n-2):
    d[i+2] = min(d[i]+np.abs(h[i+2]-h[i]), d[i+1]+np.abs(h[i+2]-h[i+1]))



import pandas as pd
df = pd.DataFrame(d)

print(d[n-1])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

import numpy as np

d = [0] * n

d[1] = np.abs(h[1] - h[0])

for i in range(n-2):
    d[i+2] = min(d[i]+np.abs(h[i+2]-h[i]), d[i+1]+np.abs(h[i+2]-h[i+1]))

print(d[n-1])
a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))
  else:
    if x.pop() != 0:
      print(0)
      exit()
    for i in range(0,a,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]

A.sort()
B = [abs(a-b) for a,b in zip(range(N-1,-1,-1),range(N))]
B.sort()

if A==B:
    print(pow(2,N//2,10**9+7))
else:
    print(0)
while 1:
   x = int(raw_input())
   y = int(raw_input())
      if x == 0 and y == 0:
      break
   print '%s %s' %(x, y)

### FIXED CODE ###

while 1:
   x,y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   if y >= x:
      print '%s %s' % (x, y)
   else:
      print '%s %s' % (y, x)
a,b,c,d=map(int,input().split())
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
e=lcm(c,d)    
ans=(b-a+1)-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e)
print(ans)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
import fractions
e=(c*d)//fractions.gcd(c,d)
ans=(b-a+1)-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//e-(a-1)//e)
print(ans)
import collections
n = raw_input()
cc = collections.Counter([raw_input() for _ in range(n)])

for u in ['AC', 'WA', 'TLE', 'RE']:
	print '{}x{}'.format(u, cc[u])

### FIXED CODE ###

import collections
n = int(raw_input())
cc = collections.Counter([raw_input() for _ in range(n)])

for u in ['AC', 'WA', 'TLE', 'RE']:
	print '{} x {}'.format(u, cc[u])
N,M=map(int,input().split())
unionfindTree = [i for i in range(N)]
size = [1 for _ in range(N)]
inconvenience = N*(N-1)//2
answers = [inconvenience]

def root(x):
    p = unionfindTree[x]
    if x==p:
        return(p)
    else:
        unionfindTree[x] = root(p)
        return(unionfindTree[x])

def union(x,y):
    rx = root(x)
    ry = root(y)
    convenience = 0
    if rx != ry:
        unionfindTree[ry] = rx
        sx = size[rx]
        sy = size[ry]
        convenience = sx * sy
        size[rx] = sx+sy
    return(convenience)

revBridges = []
for _ in range(M):
    a,b = map(int,input().split())
    revBridges.append((a-1,b-1))

for i in range(M):
    a,b = revBridges[M-1-i]
    c = union(a,b)
    inconvenience -= c
    answers.append(inconvenience)

for i in range(M):
    print(answers[M-1-i])

### FIXED CODE ###

N,M = map(int,input().split())
edges = []
for _ in range(M):
    a,b = map(int,input().split())
    edges.append((a-1,b-1))
edges.reverse()
parents = list(range(N))
size = [1 for _ in range(N)]
rank = [0 for _ in range(N)]

def root(x):
    px = parents[x]
    if px == x:
        return(x)
    else:
        r = root(px)
        parents[x] = r
        return(r)

def same(x,y):
    return(root(x) == root(y))

def union(x,y):
    rx = root(x)
    ry = root(y)
    if rx == ry:
        return(0)
    if rank[ry] > rank[rx]:
        parents[rx] = ry
        size[ry] += size[rx]
    else:
        parents[ry] = rx
        size[rx] += size[ry]
        if rank[rx] == rank[ry]:
            rank[rx] += 1
    return(1)

inconvinience = N*(N-1)//2
answers=[inconvinience]

for edge in edges:
    x,y = edge
    rx = root(x)
    ry = root(y)
    sx = size[rx]
    sy = size[ry]
    res = union(rx,ry)
    if res == 1:
        inconvinience -= sx*sy
    answers.append(inconvinience)

answers.reverse()

for answer in answers[1:]:
    print(answer)
l=int(input())
if 7 in l:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

l=input()
if "7" in l:
    print("Yes")
else:
    print("No")
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = []
D = defaultdict(lambda: [])
for i in range(N + M - 1):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
    D[a - 1].append(b - 1)

z = [0]*N
for a, b in AB:
    z[b] += 1

ans = [-1]*N
root = z.index(0)
ok = [False]*N
def rec(u, p):
    ans[u] = p
    ok[u] = True
    for v in D[u]:
        z[v] -= 1
    for v in D[u]:
        if z[v] == 0 and not ok[v]:
            rec(v, u)


rec(root, -1)

for i in range(N):
    print(ans[i] + 1)


### FIXED CODE ###

N, A, B = map(int, input().split())
a = min(A, B)
b = max(0, A + B - N)
print(a, b)
import collections
N = int(input())
A = list(map(int,input().split()))
CA = collections.Counter(A)
S = 0
for i in CA.values():
    S += i*(i-1)//2
for x in A:
    print(S - count[x] + 1)

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int,input().split()))
CA = collections.Counter(A)
S = 0
for i in CA.values():
    S += i*(i-1)//2
for x in A:
    print(S - CA[x] + 1)
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

idx = [0, 1, 2]
output = []
for i in range(1 << len(idx)):
    ops = ['+', '+', '+']
    if A+B+C+D == 7: 
        print(f'{A}{ops[0]}{B}{ops[1]}{C}{ops[2]}{D}=7')
        exit()
    
    ans = A
    for j in range(len(idx)):
        if ((i >> j) & 1) == 1:
            ops[j] = '-'
    
    if ops[0] == '+' : ans += B
    else : ans -= B
    
    if ops[1] == '+' : ans += C
    else : ans -= C
    
    if ops[2] == '+' : ans += D
    else : ans -= D
    
    if ans == 7:
        print(f'{A}{ops[0]}{B}{ops[1]}{C}{ops[2]}{D}=7')
        exit()
        

### FIXED CODE ###

S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

idx = [0, 1, 2]
output = []
for i in range(1 << len(idx)):
    ops = ['+', '+', '+']
    if A+B+C+D == 7: 
        print(A,ops[0],B,ops[1],C,ops[2],D,'=7',sep='')
        exit()
    
    ans = A
    for j in range(len(idx)):
        if ((i >> j) & 1) == 1:
            ops[j] = '-'
    
    if ops[0] == '+' : ans += B
    else : ans -= B
    
    if ops[1] == '+' : ans += C
    else : ans -= C
    
    if ops[2] == '+' : ans += D
    else : ans -= D
    
    if ans == 7:
        print(A,ops[0],B,ops[1],C,ops[2],D,'=7',sep='')
        exit()
#A


s = input().split("/")
if (s[1] == "04" or s[1] == "4" )and s[2] == "30":
    print("Heisei")
else:
    print("TBD")

#B

n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)


### FIXED CODE ###

#A

"""
s = input().split("/")
if int(s[1]) <= 4:
    print("Heisei")
else:
    print("TBD")

#B
"""
n = int(input())
ans = 0
for i in range(n):
    a = input().split()
    if a[1] == "JPY":
        ans += int(a[0])
    else:
        ans +=  float(a[0]) * 380000
print(ans)