t = int(input())
for i in range(t):
n, m = map(int, input().split())
s = []
for j in range(n):
s.append(input())
minx = 10 ** 9
miny = 10 ** 9
for x in range(n):
for y in range(m):
if s[x][y] == 'R':
minx = min(minx, x)
miny = min(miny, y)
print('YES' if s[minx][miny] == 'R' else 'NO')
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll MOD=1000000007;
// vector<ll> seive(ll n){ //vector of primes in [1,n]
// vector <ll> isPrime(n+1,1);
// vector <ll> temp;
// isPrime[0]=isPrime[1]=0;
// for(ll i=2;i<n+1;i++){
// if(isPrime[i]){
// for(ll j=i*i;j<n+1;j+=i){
// isPrime[j]=0;
// }
// }
// }
// for(ll i=0;i<n+1;i++){
// if(isPrime[i]) temp.push_back(i);
// }
// return temp;
// }
// ll power(ll a,ll b){
// ll ans=1;
// while(b){
// if(b&1) ans*=a;
// a=a*a;
// b=b>>1;
// }
// return ans;
// }
void solve(){
ll n,m;
cin >> n >> m;
char a[n][m];
ll mx=INT_MAX,my=INT_MAX;
ll rf=0;
for(ll i=0;i<n;i++){
for(ll j=0;j<m;j++){
cin >> a[i][j];
if(a[i][j]=='R'){
rf=1;
mx=min(mx,i);
my=min(my,j);
}
}
}
if(rf==0) {cout << "NO" << endl; return;}
if(a[mx][my]=='R') cout << "YES" << endl;
else cout << "NO" << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// solve();
ll t; cin >> t;
while(t--){
solve();
}
}
22B - Bargaining Table | 1490B - Balanced Remainders |
264A - Escape from Stones | 1506A - Strange Table |
456A - Laptops | 855B - Marvolo Gaunt's Ring |
1454A - Special Permutation | 1359A - Berland Poker |
459A - Pashmak and Garden | 1327B - Princesses and Princes |
1450F - The Struggling Contestant | 1399B - Gifts Fixing |
1138A - Sushi for Two | 982C - Cut 'em all |
931A - Friends Meeting | 1594A - Consecutive Sum Riddle |
1466A - Bovine Dilemma | 454A - Little Pony and Crystal Mine |
2A - Winner | 1622B - Berland Music |
1139B - Chocolates | 1371A - Magical Sticks |
1253A - Single Push | 706B - Interesting drink |
1265A - Beautiful String | 214A - System of Equations |
287A - IQ Test | 1108A - Two distinct points |
1064A - Make a triangle | 1245C - Constanze's Machine |