s=list(input().split("T"))

#print s

x,y=list(map(int,input().split()))

cx,cy=len(s[0]),0

lx=[len(_) for _ in s[2::2]]

ly=[len(_) for _ in s[1::2]]

#print lx

#print ly



memo_x=[set((cx,))]

for ind_i,i in enumerate(lx):

	next_memo_x = set()

	for j in memo_x[ind_i]:

		next_memo_x.add(j+i)		

		next_memo_x.add(j-i)

	memo_x.append(next_memo_x)

#print memo_x





memo_y=[set((cy,))]

for ind_i,i in enumerate(ly):

	next_memo_y = set()

	for j in memo_y[ind_i]:

		next_memo_y.add(j+i)		

		next_memo_y.add(j-i)

	memo_y.append(next_memo_y)

#print memo_y



if x in memo_x[-1] and y in memo_y[-1]:

	print("Yes")

else:

	print("No")





s=list(input().split("T"))

x,y=list(map(int,input().split()))

lx=[len(_) for _ in s[2::2]]

ly=[len(_) for _ in s[1::2]]



dpx=set()

dpx.add(len(s[0]))

for i in lx:

	tmp=set()

	for j in dpx:

		tmp.add(j+i)

		tmp.add(j-i)

	dpx=tmp





dpy=set()

dpy.add(0)

for i in ly:

	tmp=set()

	for j in dpy:

		tmp.add(j+i)

		tmp.add(j-i)

	dpy=tmp



print("Yes" if x in dpx and y in dpy else "No")

s = list(input().split("T"))
# print s
x, y = list(map(int, input().split()))
cx, cy = len(s[0]), 0
lx = [len(_) for _ in s[2::2]]
ly = [len(_) for _ in s[1::2]]
# print lx
# print ly
memo_x = [set((cx,))]
for ind_i, i in enumerate(lx):
    next_memo_x = set()
    for j in memo_x[ind_i]:
        next_memo_x.add(j + i)
        next_memo_x.add(j - i)
    memo_x.append(next_memo_x)
# print memo_x
memo_y = [set((cy,))]
for ind_i, i in enumerate(ly):
    next_memo_y = set()
    for j in memo_y[ind_i]:
        next_memo_y.add(j + i)
        next_memo_y.add(j - i)
    memo_y.append(next_memo_y)
# print memo_y
if x in memo_x[-1] and y in memo_y[-1]:
    print("Yes")
else:
    print("No")

s = list(input().split("T"))
x, y = list(map(int, input().split()))
lx = [len(_) for _ in s[2::2]]
ly = [len(_) for _ in s[1::2]]
dpx = set()
dpx.add(len(s[0]))
for i in lx:
    tmp = set()
    for j in dpx:
        tmp.add(j + i)
        tmp.add(j - i)
    dpx = tmp
dpy = set()
dpy.add(0)
for i in ly:
    tmp = set()
    for j in dpy:
        tmp.add(j + i)
        tmp.add(j - i)
    dpy = tmp
print("Yes" if x in dpx and y in dpy else "No")

-# print s -cx, cy = len(s[0]), 0 -# print lx -# print ly -memo_x = [set((cx,))] -for ind_i, i in enumerate(lx): -    next_memo_x = set() -    for j in memo_x[ind_i]: -        next_memo_x.add(j + i) -        next_memo_x.add(j - i) -    memo_x.append(next_memo_x) -# print memo_x -memo_y = [set((cy,))] -for ind_i, i in enumerate(ly): -    next_memo_y = set() -    for j in memo_y[ind_i]: -        next_memo_y.add(j + i) -        next_memo_y.add(j - i) -    memo_y.append(next_memo_y) -# print memo_y -if x in memo_x[-1] and y in memo_y[-1]: -    print("Yes") -else: -    print("No") +dpx = set() +dpx.add(len(s[0])) +for i in lx: +    tmp = set() +    for j in dpx: +        tmp.add(j + i) +        tmp.add(j - i) +    dpx = tmp +dpy = set() +dpy.add(0) +for i in ly: +    tmp = set() +    for j in dpy: +        tmp.add(j + i) +        tmp.add(j - i) +    dpy = tmp +print("Yes" if x in dpx and y in dpy else "No")