
def solve(n,m,z):
  for row in range(0,n+2):    
    for col in range(1,m+1):
      if z[row][col] =='B':        
        # wallin
        for h,v in [[0,1],[0,-1],[1,0],[-1,0]]:
          who = z[row+v][col+h]
          if who == 'G':
            return False
          if who == '.':
            z[row+v][col+h]='#'
  
  gexists = False
  for x in z:
    if 'G' in x:
      gexists = True
  
  if not gexists:
    
    return True


  walk(z,n,m)

  for x in z:
    if 'G' in x:
      return False
  return True


    
    
def p(z):
  return
  print()
  [print(''.join(x)) for x in z]

def walk( z,x,y):
  if z[x][y] in '# ':
    return
  p(z)
  z[x][y]=' '
  for h,v in [[0,1],[0,-1],[1,0],[-1,0]]:
    if z[x+h][y+v] not in '# ':
      walk(z,x+v,y+h)

def main():
  for _ in range(int(input())):
    #print('\n- - - - - - - - - -\n')
    z=list()
    n,m=[int(x) for x in input().split()]
    w = '#'*(m+2)
    z=[w]+['#'+input()+'#' for _ in range(n)]+[w]
    z=[list(x) for x in z]
    p(z)
    res = solve(n,m,z)
    
    if res:
      print("Yes")
    else:
      print("No")
    p(z)





main()
