#include <bits/stdc++.h>
using namespace std;
const int N=210;
char a[N][N];
bool vis[N][N];
int yao[N][N];
int dx[4]={0,0,-1,1},n,m;
int dy[4]={-1,1,0,0};
struct res{
int x;
int y;
int enr;
};
void bfs(res st,int ex,int ey){
if(yao[st.x][st.y]==0){
cout<<"No";
return ;
}
else st.enr=yao[st.x][st.y];
res next,now;
vis[st.x][st.y]=1;
queue<res> q;
q.push(st);
while(!q.empty()){
now=q.front();
if(now.x==ex&&now.y==ey){
cout<<"Yes";
return ;
}
if(now.enr==0&&yao[next.x][next.y]<=0) {
cout<<"No";
return ;
}
for(int i=0;i<4;i++){
next.x=now.x+dx[i];
next.y=now.y+dy[i];
if(next.x>=1&&next.x<=n&&next.y>=1&&next.y<=m&&vis[next.x][next.y]==0&&(yao[next.x][next.y]==0||yao[next.x][next.y]>now.enr)&&a[next.x][next.y]!='#'){
if(yao[next.x][next.y]==0){
next.enr=now.enr-1;
}
else next.enr=yao[next.x][next.y];
yao[next.x][next.y]=-1;
vis[next.x][next.y]=1;
q.push(next);
}
}
q.pop();
}
return ;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){cin>>a[i][j];}
}
int e;
cin>>e;
while(e--){
int xx,yy,e1;
cin>>xx>>yy>>e1;
a[xx][yy]='Y';
yao[xx][yy]=e1;
}
int sx,sy,ex,ey;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='S') sx=i,sy=j;
if(a[i][j]=='T') ex=i,ey=j;
}
}
res temp;
temp.x=sx,temp.y=sy;
bfs(temp,ex,ey);
return 0;
}