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
from collections import defaultdict, deque


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


def arr2d(rows, cols, v=0): return [
    [v for i in range(cols)] for _ in range(rows)]


r, c = number_list()
arr = arr2d(r, c, '')
g = defaultdict(list)

visited = set()


class Node:
    def __init__(self, node):
        self.path = [node]
        self.node = node
        self.turns = 0

    def is_turn(self):
        if len(self.path) > 2:
            r_now, c_now = list(map(int, self.path[-1].split('-')))
            r_parent, c_parent = list(map(int, self.path[-2].split('-')))
            r_grand, c_grand = list(map(int, self.path[-3].split('-')))

            if r_grand == r_parent and (r_now != r_grand):
                return True
            if r_now == r_parent and (r_now != r_grand):
                return True
            

        return False

    def set_parent(self, node):
        cur_path = []
        if len(node.path) > 1:
            cur_path.append(node.path[-2])
        cur_path.append(node.path[-1])
        cur_path.append(self.node)

        self.path = cur_path

    def __eq__(self, other):
        return self.node == other.node

    def __repr__(self):
        return self.node + ": {}".format(self.turns)

found = False
def dfs(s, d, g):
    global found
    if s.node == d and s.turns < 3:
        found = True

    visited.add(s.node)
    # print(s)
    nodes = g.get(s.node)
    # print(nodes)
    if nodes:
        for node in nodes:
            if node in visited:
                continue
            node = Node(node)
            node.set_parent(s)
            node.turns += s.turns
            node.turns += int(node.is_turn())
            dfs(node, d, g)


for i in range(r):
    col = input()
    for j, char in enumerate(col):
        arr[i][j] = char

s, d = -1, -1
for i in range(r):
    for j in range(c):
        if arr[i][j] != '*' and j + 1 < c and arr[i][j + 1] != '*':
            curr_cell = str(i) + '-' + str(j)
            next_cell = str(i) + '-' + str(j + 1)
            g[curr_cell].append(next_cell)
            g[next_cell].append(curr_cell)

        if arr[i][j] != '*' and i + 1 < r and arr[i + 1][j] != '*':
            curr_cell = str(i) + '-' + str(j)
            next_cell = str(i + 1) + '-' + str(j)
            g[curr_cell].append(next_cell)
            g[next_cell].append(curr_cell)

        if arr[i][j] == 'S':
            s = str(i) + '-' + str(j)
        if arr[i][j] == 'T':
            d = str(i) + '-' + str(j)

source = Node(s)
dfs(source, d, g)
if found:
    print("YES")
else:
    print("NO")

# print(s,d)

