S = eval(input())+"T"

X,Y = list(map(int,input().split()))

dX0,dX,dY,dr,dc = 0,[],[],"x",0

for s in S:

    if s == "F":

        dc += 1

    elif s == "T":

        if dr == "x":

            dr = "y"

            dX.append(dc)

        else:

            dr = "x"

            dY.append(dc)

        dc = 0

dX0,dX = dX[0],dX[1:]



canX,canY = [dX0],[0]

for dx in dX:

    t = []

    for cx in canX:

        t.append(cx+dx)

        t.append(cx-dx)

    canX = list(set(t))



for dy in dY:

    t = []

    for cy in canY:

        t.append(cy+dy)

        t.append(cy-dy)

    canY = list(set(t))



print(("Yes" if X in canX and Y in canY else "No"))
S = eval(input())

X,Y = list(map(int,input().split()))



S = S+"T"

d,cnt = 0,0

pos = [set([0]),set([0])]

init = False

for s in S:

    # 前進

    if s=="F":

        cnt += 1

    # 方向転換

    else:

        # 移動先を全列挙

        if cnt>0:

            temp = set([])

            for p in pos[d]:

                temp.add(p+cnt)

                if init:

                    temp.add(p-cnt)

            pos[d] = temp

        # 方向転換

        d = (d+1)%2

        cnt = 0

        # 初回の方向転換を終えたかどうか

        init = True



print(("Yes" if X in pos[0] and Y in pos[1] else "No"))
S = eval(input()) + "T"
X, Y = list(map(int, input().split()))
dX0, dX, dY, dr, dc = 0, [], [], "x", 0
for s in S:
    if s == "F":
        dc += 1
    elif s == "T":
        if dr == "x":
            dr = "y"
            dX.append(dc)
        else:
            dr = "x"
            dY.append(dc)
        dc = 0
dX0, dX = dX[0], dX[1:]
canX, canY = [dX0], [0]
for dx in dX:
    t = []
    for cx in canX:
        t.append(cx + dx)
        t.append(cx - dx)
    canX = list(set(t))
for dy in dY:
    t = []
    for cy in canY:
        t.append(cy + dy)
        t.append(cy - dy)
    canY = list(set(t))
print(("Yes" if X in canX and Y in canY else "No"))

S = eval(input())
X, Y = list(map(int, input().split()))
S = S + "T"
d, cnt = 0, 0
pos = [set([0]), set([0])]
init = False
for s in S:
    # 前進
    if s == "F":
        cnt += 1
    # 方向転換
    else:
        # 移動先を全列挙
        if cnt > 0:
            temp = set([])
            for p in pos[d]:
                temp.add(p + cnt)
                if init:
                    temp.add(p - cnt)
            pos[d] = temp
        # 方向転換
        d = (d + 1) % 2
        cnt = 0
        # 初回の方向転換を終えたかどうか
        init = True
print(("Yes" if X in pos[0] and Y in pos[1] else "No"))

-S = eval(input()) + "T" +S = eval(input()) -dX0, dX, dY, dr, dc = 0, [], [], "x", 0 +S = S + "T" +d, cnt = 0, 0 +pos = [set([0]), set([0])] +init = False +    # 前進 -        dc += 1 -    elif s == "T": -        if dr == "x": -            dr = "y" -            dX.append(dc) -        else: -            dr = "x" -            dY.append(dc) -        dc = 0 -dX0, dX = dX[0], dX[1:] -canX, canY = [dX0], [0] -for dx in dX: -    t = [] -    for cx in canX: -        t.append(cx + dx) -        t.append(cx - dx) -    canX = list(set(t)) -for dy in dY: -    t = [] -    for cy in canY: -        t.append(cy + dy) -        t.append(cy - dy) -    canY = list(set(t)) -print(("Yes" if X in canX and Y in canY else "No")) +        cnt += 1 +    # 方向転換 +    else: +        # 移動先を全列挙 +        if cnt > 0: +            temp = set([]) +            for p in pos[d]: +                temp.add(p + cnt) +                if init: +                    temp.add(p - cnt) +            pos[d] = temp +        # 方向転換 +        d = (d + 1) % 2 +        cnt = 0 +        # 初回の方向転換を終えたかどうか +        init = True +print(("Yes" if X in pos[0] and Y in pos[1] else "No"))