Harryxun/stf_run huggingface dataset:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil

def main():
  n = int(input())
  for i in range(n):
    t, a = map(int, input().split())
    if i == 0:
      nt, na =  t, a
      continue
    cands = list(filter(lambda x: x[0] >= nt and x[1] >= na, [(ceil(nt/t)*t, ceil(nt/t)*a), (ceil(na/a)*t, ceil(na/a)*a)]))
    nt, na = min(cands)
  print(nt + na)

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

def ceil(a, b):
  return (a + b - 1) // b

def main():
  n = int(input())
  nt, na = 1, 1
  for i in range(n):
    t, a = map(int, input().split())
    r = max([ceil(nt, t), ceil(na, a)])
    nt, na = r*t, r*a
  print(nt + na)

if __name__=='__main__':
  main()
a, b, c = map(int, input().split())
if a == b == c:
    print(1)
elif: a == b or b == c or c == a:
    print(2)
else:
	print(3)

### FIXED CODE ###

a, b, c = map(int, input().split())
if a == b == c:
    print(1)
elif a == b != c or b == c != a or c == a != b:
    print(2)
else:
	print(3)
N = map(int,input().split())
sum = 0

#文字になるときpass
for i in range(N):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 15 == 0 :
        pass
    else:
         sum +=  i

print(sum)


### FIXED CODE ###

n = int(input())
sum = 0
 
for i in range(n+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 15 == 0:
        pass
    else:
     sum += i
 
print (sum)
a = int(input())
b = int(input())

if a % b == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

a,b  = map(int, input().split())

if (a*b) %2 == 0:
  print("Even")
else:
  print('Odd')
import sys

def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 100000
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        ti = A - y
        titen.append(ti)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)

def main():
    print(solve(*readQuestion()))

# Uncomment before submission
 main()

### FIXED CODE ###

import sys
 
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 10**5//1
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        til = A - y
        titen.append(til)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 # Uncomment before submission
main()
a,b=input(),input()
print a*b
print 2*a+2*b

### FIXED CODE ###

a = map(int, raw_input().split())
print a[0]*a[1],2*a[0]+2*a[1]
D = int(input())

if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve')
elif = D == 22:
  print('Christmas Eve Eve Eve')
  

### FIXED CODE ###

D = int(input())
 
if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve')
elif D == 22:
  print('Christmas Eve Eve Eve')
def yo():
    l,r = map(int,input().split())

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
 
            if(ij==0) :
                return a

            if (a > ij) :
                a = ij


    return a



print(yo())

### FIXED CODE ###

n,a,b = map(int,input().split())

if( a*n < b ) :
    print(a*n)
else :
    print(b)
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = a*2
# 文字列の入力
s = input()
# 出力
print("{}".format(a/b, s))

### FIXED CODE ###

print(int(input())**2)
a, b, c, d = map(int, input()split())

if a + b > c + d:
	print("Left")
elif a + b == c + d:
	print("Balanced")
else:
	print("Right")

### FIXED CODE ###

a, b, c, d = map(int, input().split())

if a + b > c + d:
	print("Left")
elif a + b == c + d:
	print("Balanced")
else:
	print("Right")
# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                ans += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

    print(N-count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                count += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

    print(N-count)


if __name__ == '__main__':
    main()
S=list(input())
a=0
for j in range(0,len(S),2):
    if S[i]=="R" or S[i]=="U" or S[i]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S=list(input())
a=0
for j in range(0,len(S),2):
    if S[j]=="R" or S[j]=="U" or S[j]=="D":
        a+=1
for i in range(1,len(S),2):
    if S[i]=="L" or S[i]=="U" or S[i]=="D":
        a+=1
if a==len(S):
    print("Yes")
else:
    print("No")
# coding: utf-8
# Your code here!
import math
N = int(input())

def divisor(N):
    lst = []
    for i in range(2,math.ceil(math.sqrt(N))+1):
        if N%i == 0:
            lst.append(i)
            if i != int(N/i):
                lst.append(int(N/i))
    lst.sort()
    return lst
    
ans = divisor(N)
#print(ans,len(ans))
A = ans[len(ans)//2-1]
B = ans[len(ans)//2]
#print(A,B,A*B)
if A*B == N and len(ans)>1:
    print(A+B-2)
elif B**2 == N and len(ans)>1:
    print(2*B-2)
else:
    print(N-1)
  
    

### FIXED CODE ###

# coding: utf-8
# Your code here!
import math
import sys
N = int(input())

def divisor(N):
    lst = []
    for i in range(2,math.ceil(math.sqrt(N))+1):
        if N%i == 0:
            lst.append(i)
            #if i != int(N/i):
                #lst.append(int(N/i))
    #lst.sort()
    return lst
    
ans = divisor(N)
#print(ans,len(ans))
if N == 2:
    print(1)
    sys.exit()
    
if len(ans) > 0:
    A = ans[-1]
    if A*A < N:
        B = int(N/A)
        print(A+B-2)
    else:
        print(2*A-2)
else:
    print(N-1)

'''
if len(ans)%2 == 0 and len(ans)>1:
    A = ans[len(ans)//2-1]
    B = ans[len(ans)//2]
    #print(A,B)
    print(A+B-2)
elif len(ans)%2 == 1 and len(ans)>1:
    A = ans[len(ans)//2]
    print(2*A-2)
else:
    print(N-1)
'''
n=int(input())
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)

### FIXED CODE ###

n=int(input())
sp=[]
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    if int(sp[i][1])==0:
        sp[i][1]=float('inf')
    else:
        sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)
import sys
n=int(input())
s=[input()[0] for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
    if s[i]=="M": m+=1
    elif s[i]=="A": a+=1
    elif s[i]=="R": r+=1
    elif s[i]=="C": c+=1
    elif s[i]=="H": h+=1
t=sorted([m,a,r,c,h])
if t[2]==0:
    print(0)
    sys.exit()
if t[1]==0:
    print(t[2]*t[3]*t[4])
    sys.exit()
if t[0]==0:
    t[1],t[2],t[3],t[4]=a,b,c,d
    print(a*b*c+a*b*d+a*c*d+b*c*d)
    sys.exit()
else:
    t[0],t[1],t[2],t[3],t[4]=a,b,c,d,e
    x=a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e
    y=b*c*d+b*c*e+b*d*e+c*d*e
    print(x+y)

### FIXED CODE ###

import sys
n=int(input())
s=[input()[0] for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
    if s[i]=="M": m+=1
    elif s[i]=="A": a+=1
    elif s[i]=="R": r+=1
    elif s[i]=="C": c+=1
    elif s[i]=="H": h+=1
t=sorted([m,a,r,c,h])
q,w,e,r,u=0,0,0,0,0
if t[2]==0:
    print(0)
    sys.exit()
if t[1]==0:
    print(t[2]*t[3]*t[4])
    sys.exit()
if t[0]==0:
    q,w,e,r=t[1],t[2],t[3],t[4]
    print(q*w*e+q*w*r+q*e*r+w*e*r)
    sys.exit()
else:
    q,w,e,r,u=t[0],t[1],t[2],t[3],t[4]
    x=q*w*e+q*w*r+q*w*u+q*e*r+q*e*u+q*r*u
    y=w*e*r+w*e*u+w*r*u+e*r*u
    print(x+y)
n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
for i in range(n):
  fp = lista[fp]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)
       

### FIXED CODE ###

n = int(input())
lista = []
for i in range(n):
  lista.append(int(input()))

count = 1
fp = lista[0]
if fp == 2:
  print(count)
  exit()

for i in range(n):
  fp = lista[fp-1]
  count += 1
  if fp == 2:
    print(count)
    exit()
print(-1)
a = list(map(int,input().split()))
print(a - b + 1)

### FIXED CODE ###

a,b = map(int,input().split())
print(a- b + 1)
N = int(input())
a = list( map(int, input().split() ) )
result = float()
for i in range(N-1):
    result += (a[N-1] - a[i]) / ( i+1 )

for i in range(1,N):
    result *= i

if result.is_integer():
    result = int(result)
else:
    result = int(result)+1
    
print( result % (10**9+7) )

### FIXED CODE ###

N = int(input())
d = list( map(int, input().split() ) )
kai = 1
mod = 10**9+7
result = 0

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

for i in range(1,N):
    kai = (kai%mod)*i

for i in range(N-1):    
    result += ( kai * (d[N-1] - d[i]) * modinv(i+1) ) % mod 

print( result%mod )
N = int(input())

cnt_dict = {}

for i in range(N):
    s_str = "".join(sorted(str))
    if s_str not in cnt_dict.keys():
        cnt_dict[s_str] = 1
        continue
    cnt_dict[s_str] += 1

import itertools
comb = itertools.combinations

total = 0
for key in cnt_dict.keys():
    cnt = cnt_dict[key]
    if cnt < 2:
        continue
    total += len(list(comb(range(cnt), 2)))

print(total)

### FIXED CODE ###


N = int(input())

cnt_dict = {}

for i in range(N):
    s_list = list(input())
    s_list.sort()
    s_str = "".join(s_list)
    if s_str not in cnt_dict.keys():
        cnt_dict[s_str] = 1
        continue
    cnt_dict[s_str] += 1

import itertools
comb = itertools.combinations

total = 0
for key in cnt_dict.keys():
    cnt = cnt_dict[key]
    if cnt < 2:
        continue
    total += cnt * (cnt - 1) // 2

print(total)
import numpy as np
import itertools
#N, M = list(map(int, input().split()))
N = 2
M = 2
tmp = [[int(i) for i in input().split()] for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for switch in itertools.product(range(2),repeat=N):
    #print(switch)
    num_clear_light = 0
    for i in range(M):
        count = 0
        for j in range(tmp[i][0]):
            #print(tmp[i][j+1])
            if(switch[tmp[i][j+1] - 1] == 1):
                count += 1
        if(count % 2 == p[i]):
            num_clear_light += 1
    if(num_clear_light == M):
        ans += 1
    num_clear_light = 0

print(ans)

### FIXED CODE ###

import numpy as np
import itertools
N, M = list(map(int, input().split()))
tmp = [[int(i) for i in input().split()] for i in range(M)]
p = list(map(int, input().split()))
ans = 0
for switch in itertools.product(range(2),repeat=N):
    #print(switch)
    num_clear_light = 0
    for i in range(M):
        count = 0
        for j in range(tmp[i][0]):
            #print(tmp[i][j+1])
            if(switch[tmp[i][j+1] - 1] == 1):
                count += 1
        if(count % 2 == p[i]):
            num_clear_light += 1
    if(num_clear_light == M):
        ans += 1
    num_clear_light = 0

print(ans)
[n,w] = [int(i) for i in input().split()]
w_v = []
for i in range(n):
    w_v.append([int(j) for j in input().split()])

"""
dp[i][v] = w
i : 何番目までのものを使うか
v : ちょうどその価値になる
w : その時の重さ
最後に後ろから全探索して重さ超えてないやつ探す？
"""
INF = 10 ** 9 + 7
v_max = 10**3 * n
dp = [[INF] * (v_max) for i in range(n)]
##print(dp)
#価値0になるところの重さは0
for i in range(n):
    dp[i][0] = 0

for i in range(n):
    #print("step",i)
    if i != 0:
        for v_zantei in range(v_max):
            if v_zantei >= w_v[i][1]:
                dp[i][v_zantei] = min(dp[i-1][v_zantei],dp[i-1][v_zantei - w_v[i][1]] + w_v[i][0])
            else:
                dp[i][v_zantei] = dp[i-1][v_zantei]
        #print(dp[i])
    else:
        dp[i][w_v[i][1]] = w_v[i][0]
        #print(dp[i])
ans = -1
for v in range(v_max-1,-1,-1):
    #print(w,dp[n-1][v],ans)
    if dp[n-1][v] <= w and ans < v:
        ##print(v)
        ans = v
print(ans)


### FIXED CODE ###

[n,w] = [int(i) for i in input().split()]
w_v = []
for i in range(n):
    w_v.append([int(j) for j in input().split()])

"""
dp[i][v] = w
i : 何番目までのものを使うか
v : ちょうどその価値になる
w : その時の重さ
最後に後ろから全探索して重さ超えてないやつ探す？
"""
INF = 10 ** 9 + 7
v_max = 10**3 * n + 1
dp = [[INF] * (v_max) for i in range(n)]
##print(dp)
#価値0になるところの重さは0
for i in range(n):
    dp[i][0] = 0
if n != 1:
    for i in range(n):
        #print("step",i)
        if i != 0:
            for v_zantei in range(v_max):
                if v_zantei >= w_v[i][1]:
                    dp[i][v_zantei] = min(dp[i-1][v_zantei],dp[i-1][v_zantei - w_v[i][1]] + w_v[i][0])
                else:
                    dp[i][v_zantei] = dp[i-1][v_zantei]
            #print(dp[i])
        else:
            dp[i][w_v[i][1]] = w_v[i][0]
            #print(dp[i])
    ans = -1
    for v in range(v_max-1,-1,-1):
        #print(w,dp[n-1][v],ans)
        if dp[n-1][v] <= w and ans < v:
            ##print(v)
            ans = v
    print(ans)
else:
    print(w_v[0][1])
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

A, B, C, D = map(int, input().split())
count = 0
BCcount = B // C
BDcount = B // D
ACcount = (A - 1) // C
ADcount = (A - 1) // D
l = C * D // gcd(C, D)
BCDcount = B // l
ACDcount = (A - 1) // l
Bcount = Decimal(B - (BCcount + BDcount - BCDcount))
Acount = Decimal((A - 1) - (ACcount + ADcount - ACDcount))
print(Decimal(Bcount - Acount))

### FIXED CODE ###

from decimal import Decimal
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

A, B, C, D = map(int, input().split())
count = 0
BCcount = B // C
BDcount = B // D
ACcount = (A - 1) // C
ADcount = (A - 1) // D
l = C * D // gcd(C, D)
BCDcount = B // l
ACDcount = (A - 1) // l
Bcount = Decimal(B - (BCcount + BDcount - BCDcount))
Acount = Decimal((A - 1) - (ACcount + ADcount - ACDcount))
print(Decimal(Bcount - Acount))
# coding: utf-8
# Here your code !
a,b,c = input().split()
if(a < B < c):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# coding: utf-8
# Here your code !
a,b,c = input().split()
if(a < b < c):
    print('Yes')
else:
    print('No')
import math
a, b=[int(i) for i in input().split()]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

m=lcm(a, b)  
print(m)

### FIXED CODE ###

A, B=[int(i) for i in input().split()]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
  
print(lcm(A,B))
N = int(input())
H = list(list(map(int,input().split())) for _ in range(N))
#sub problem: max cost from 0 to ith day
def rec(i, choice):
  if i == len(H):
    return 0
  return max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
print(max(rec(0, j) for j in range(3)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
 
N = int(input())
H = list(list(map(int,input().split())) for _ in range(N))
#sub problem: max cost from 0 to ith day
memo = {}
def rec(i, choice):
  if (i, choice) in memo:
    return memo[(i, choice)]
  if i == len(H):
    return 0
  m = max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
  memo[(i, choice)] = m
  return m
print(max(rec(0, j) for j in range(3)))
s = int(input())
d = list(map,input().split())
sum = 0

for i in range(n):
  for j in range(i+1,n):
    sum += d[i]*d[j]
print(ans)
    

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
sum = 0
 
for i in range(n):
  for j in range(i+1,n):
    sum += (d[i]*d[j])
print(sum)
import sys
sys.setrecursionlimit(100000)
readline = sys.stdin.readline

N , Q = map(int,readline().rstrip().split())
G = [[] for _ in range(N)]
for n in range(N-1):
    a , b = map(int,readline().rstrip().split())
    G[a-1].append(b-1)
query = []
[query.append( list(map(int,readline().rstrip().split()))) for _ in range(Q) ]
counter = [0] * N 
# visit = []

def dfs(root , x , visit):
    if visit[root] == 0:
        visit[root] = 1
        counter[root] += x
    else:
        return 0
    
    for g in G[root]:
        dfs( g, x , visit)

    return 0

def solve():
    for q in query:
        visit = [0] * N
        dfs(q[0]-1,q[1] , visit)
    [print(c , end = " " ) for c in counter]
    print("")

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
readline = sys.stdin.readline

N , Q = map(int,readline().rstrip().split())
G = [[] for _ in range(N)]
for n in range(N-1):
    a , b = map(int,readline().rstrip().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
query = [0] * N
for q in range(Q):
    p , x = map(int,readline().rstrip().split())
    query[p-1] += x
counter = [0] * N 
visit = [0] * N

def dfs(root , x ):
    if visit[root] == 0:
        visit[root] = 1
        x += query[root]
        counter[root] += x
    else:
        return 0
    
    for g in G[root]:
        dfs( g, x )

    return 0

def solve():
    dfs(0 , 0)
    [print(c , end = " " ) for c in counter]
    print("")

if __name__ == "__main__":
    solve()
K = int(input())

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0,1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8,9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            d.append(d_)
if k <= 9:
    print(k)
else:
    cal()

### FIXED CODE ###

K = int(input())

def cal():
    count = 9
    d = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10**9):
        d_ = []
        for j in range(len(d[i])):
            a = str(d[i][j])
            if a[-1]=="0":
                for k in [0, 1]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
            elif a[-1]=="9":
                for k in [8, 9]:
                    d_.append(int(a)*10+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return 
            else:
                for k in [-1, 0, 1]:
                    d_.append(int(a)*10+int(a[-1])+k)
                    count += 1
                    if K == count:
                        print(d_[-1])
                        return
        d.append(d_)
if K <= 9:
    print(K)
else:
    cal()
import sys

def check(s, x, y):

    while s and s[0] == "F":
        s = s[1:]
        x -= 1
    while s and s[-1] == "T":
        s = s[:-1]

    d = 0
    vxs = []
    vys = []
    while s:
        while s and s[0] == "T":
            s = s[1:]
            d ^= 1
        l = 0
        while s and s[0] == "F":
            s = s[1:]
            l += 1
        if d:
            vys.append(l)
        else:
            vxs.append(l)

    def check1(vs, t):
        def check2(i, p, cache={}):
            if i == 0:
                return p == t
            if (i, p) in cache:
                return cache[i, p]
            r =  check2(i - 1, p - vs[i-1]) or check2(i - 1, p + vs[i-1])
            cache[i, p] = r
            return r
        return check2(len(vs), 0)

    r = check1(vxs, x) and check1(vys, y)
    return r

if __name__ == "__main__":
    s = sys.stdin.readline().strip()
    x, y = [int(n) for n in sys.stdin.readline().strip().split()]
    if check(s, x, y):
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

import sys

def check(s, x, y):

    while s and s[0] == "F":
        s = s[1:]
        x -= 1
    while s and s[-1] == "T":
        s = s[:-1]

    d = 0
    vxs = []
    vys = []
    while s:
        while s and s[0] == "T":
            s = s[1:]
            d ^= 1
        l = 0
        while s and s[0] == "F":
            s = s[1:]
            l += 1
        if d:
            vys.append(l)
        else:
            vxs.append(l)

    def check1(vs, t):
        a = 0
        for v in sorted(vs, reverse=True):
            if t < a:
                a -= v
            else:
                a += v
        return a == t

    r = check1(vxs, x) and check1(vys, y)
    return r

if __name__ == "__main__":
    s = sys.stdin.readline().strip()
    x, y = [int(n) for n in sys.stdin.readline().strip().split()]
    if check(s, x, y):
        print("Yes")
    else:
        print("No")
a = mlist(map(int,input().split()))
a.sort()
print(a[2] - a[0])

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
print(a[2] - a[0])
k,x = map(int,input().split())
print("Yes" if k*500 >= x "No")

### FIXED CODE ###

k,x = map(int,input().split())
print("Yes" if k*500 >= x else "No")