import math
#import math 
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
#-------------------game starts now----------------------------------------------------import math
for i in range(int(input())):
 n,m=map(int,input().split())
 matrix=[[0 for i in range(m)]for j in range(n)]
 def isPath1(): 
    visited=[[False for i in range(m)]for i in range(n)] 
    flag = False 
    for i in range(n):
            for j in range(n): 
                if matrix[i][j] == 1 and (visited[i][j]==False):
  
                    if (isPath( i, j, visited)):
                        flag = True
                        break 
    return flag
  
 def isSafe(i,j): 
     
  
        if i >= 0 and i < len(matrix) and j >= 0 and j<len(matrix[0]):
            return True; 
        return False; 
    
 def isPath(i,j,visited): 
        if isSafe(i, j) and matrix[i][j] != 0 and (visited[i][j]==False):
            visited[i][j] = True; 
  
            if (matrix[i][j] == 2) :
                return True; 
  
            up = isPath(i - 1,j, visited); 
  
            if (up==True): 
                return True; 
  
            left= isPath( i, j - 1, visited); 
  
            if (left==True) :
                return True; 
  
            down = isPath( i + 1, j, visited); 
  
            if (down==True) :
                return True; 
  
            right = isPath( i, j + 1,visited); 
  
            if (right==True) :
                return True
        return False    
 
 s=[]
 c=0
 f=0
 c1=0
 for j in range(n):
     s.append(list(input()))
 for i in range(n):
     for j in range(m):
         if s[i][j]=='B':
             s[i][j]='#'
             if i>0:
                 if s[i-1][j]=='G':
                     f=1
                     break
                 s[i-1][j]='#'
             if j>0:
                 if s[i][j-1]=='G':
                     f=1
                     break
                 s[i][j-1]='#'
             if i<n-1:
                 if s[i+1][j]=='G':
                     f=1
                     break
                 s[i+1][j]='#'
             if j<m-1:
                 if s[i][j+1]=='G':
                     f=1
                     break
                 s[i][j+1]='#'
     if f==1:
        break
 e=[] 
 if f==1:
     print("No")
     continue
 for i in range(n):
     for j in range(m):
         if s[i][j]=='.':
             matrix[i][j]=3
         if s[i][j]== '#':
             matrix[i][j]=0
         if s[i][j]=='G':
             matrix[i][j]=3
             e.append((i,j))
 f=0 
 for i in e:
     ce=matrix[i[0]][i[1]]
     ce1=matrix[n-1][m-1]
     if matrix[i[0]][i[1]]==0:
         f=1
         break
     matrix[i[0]][i[1]]=1
     if matrix[n-1][m-1]==0:
         f=1
         break
     matrix[n-1][m-1]=2
     if isPath1()==False:
         f=1
         break
     matrix[i[0]][i[1]]=ce
     matrix[n-1][m-1]=ce1
 if f==0:
     print("Yes")
 else:
     print("No")
 