Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems with the steering wheel, so he can make no more than two turns on his way to his office in bank.

Bankopolis looks like a grid of *n* rows and *m* columns. Igor should find a way from his home to the bank that has no more than two turns and doesn't contain cells with road works, or determine that it is impossible and he should work from home. A turn is a change in movement direction. Igor's car can only move to the left, to the right, upwards and downwards. Initially Igor can choose any direction. Igor is still sleepy, so you should help him.
The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 1000) — the number of rows and the number of columns in the grid.

Each of the next *n* lines contains *m* characters denoting the corresponding row of the grid. The following characters can occur: 
 -  "." — an empty cell; -  "*" — a cell with road works; -  "S" — the cell where Igor's home is located; -  "T" — the cell where Igor's office is located. 
It is guaranteed that "S" and "T" appear exactly once each.
The first sample is shown on the following picture:

In the second sample it is impossible to reach Igor's office using less that 4 turns, thus there exists no path using no more than 2 turns. The path using exactly 4 turns is shown on this picture:
5 5
S....
****.
.....
.****
..T..
NO
1 2
ST
YES
3 1
S
*
T
NO
3 3
*..
...
TS.
YES
3 3
T.*
*.*
*S*
YES
7 7
.S.****
...*.*.
.****..
.*.**.*
..T*...
***..*.
*******
YES
3 3
**T
*S*
***
NO
2 2
ST
*.
YES
2 2
S.
.T
YES
2 2
TS
.*
YES
2 2
.T
S*
YES
import sys
from collections import deque


def is_valid(r, c, n, m):
    return 0 <= r < n and 0 <= c < m


def get_neighbors(cid, dir, n, m):
    update_c = [1, 0, -1, 0]
    update_r = [0, -1, 0, 1]
    neighbors = []

    r = cid // m
    c = cid % m
    for j in [0, -1, 1]:
        cost = 1 if j != 0 else 0
        d = (dir + j + 4) % 4
        nc = c + update_c[d]
        nr = r + update_r[d]
        if is_valid(nr, nc, n, m):
            nid = nr * m + nc
            neighbors.append((nid, cost, d))
    return neighbors


def add_to_queue(cid, from_dir, cost, to_visit, blocked, n_turns):
    if not blocked[cid]:
        if n_turns[cid][from_dir] > cost:
            n_turns[cid][from_dir] = cost
            to_visit.append((cid, from_dir))


def solve(start, end, blocked, n, m):
    if start == end:
        return True

    inf = 1000 * 1000 + 1
    # n_turns: minimum number of turn to get there from each direction
    n_turns = [[inf, inf, inf, inf] for _ in range(n * m)]
    n_turns[start] = [0, 0, 0, 0]
    to_visit = deque()
    to_visit.append((start, 0))
    to_visit.append((start, 1))
    to_visit.append((start, 2))
    to_visit.append((start, 3))

    while to_visit:
        (cid, dir) = to_visit.popleft()
        if cid == end and n_turns[cid][dir] <= 2:
            return True

        for nid, cost, new_dir in get_neighbors(cid, dir, n, m):
            add_to_queue(nid, new_dir, n_turns[cid][dir] + cost, to_visit, blocked, n_turns)
    return False


# Parse inputs
n, m = map(int, next(sys.stdin).strip().split())
cid = 0
start, end = -1, -1
blocked = [False for i in range(n * m)]
for line in sys.stdin:
    cells = line.strip()
    for cell in cells:
        if cell == 'S':
            start = cid
        elif cell == 'T':
            end = cid
        elif cell == '*':
            blocked[cid] = True
        cid += 1

ans = solve(start, end, blocked, n, m)

# Print output
sys.stdout.write("{}\n".format("YES" if ans else "NO"))
