def f(n,m,maze):
 s=''.join(''.join(l) for l in maze)
 if not('G' in s): return True
 for y in xrange(n):
  for x in xrange(m):
   if maze[y][x]=='B':
    if (x,y) in [(m-1,n-2),(m-2,n-1)]: return False
    maze[y][x]='#'
    if x-1>=0:
     if (maze[y][x-1] in '.#'): maze[y][x-1]='#'
     else: return False
    if x+1<m:
     if (maze[y][x+1] in '.#'): maze[y][x+1]='#'
     else: return False
    if y-1>=0:
     if (maze[y-1][x] in '.#'): maze[y-1][x]='#'
     else: return False
    if y+1<n:
     if (maze[y+1][x] in '.#'): maze[y+1][x]='#'
     else: return False
 maze[n-1][m-1]='R'; goagain=True
 while goagain:
  goagain=False
  for d in xrange((n-1)+(m-1),-1,-1):
   minx=max(0,d-(n-1)); maxx=min(d,m-1)
   for x in xrange(minx,maxx+1):
    y=d-x
    if maze[y][x] in '#R': continue
    if   y+1<n and maze[y+1][x]=='R': maze[y][x]='R'; goagain=True
    elif x+1<m and maze[y][x+1]=='R': maze[y][x]='R'; goagain=True
  for d in xrange((n-1)+(m-1)+1):
   minx=max(0,d-(n-1)); maxx=min(d,m-1)
   for x in xrange(minx,maxx+1):
    y=d-x
    if maze[y][x] in '#R': continue
    if   y-1>=0 and maze[y-1][x]=='R': maze[y][x]='R'; goagain=True
    elif x-1>=0 and maze[y][x-1]=='R': maze[y][x]='R'; goagain=True
 s=''.join(''.join(l) for l in maze)
 return not('G' in s)
  

for t in xrange(int(raw_input())):
 n,m=map(int,raw_input().split())
 maze=[]
 for l in xrange(n): maze.append(list(raw_input()))
 print ['No','Yes'][f(n,m,maze)]
