def dfs(i,j,n,m):
    if (i,j) in visited:
        return False

    if i==0 or j==0 or j==m+1 or i==n+1 or mat[i][j]=='#':
        return False
    if i==n and j==m and (mat[i][j]!='B' or mat[i][j]!='#'):
        return True

    if dp[i][j]!=None:
        return dp[i][j]

    visited.add((i,j))

    dp[i][j] =  dfs(i+1,j,n,m) or dfs(i-1,j,n,m) or dfs(i,j+1,n,m) or dfs(i,j-1,n,m)
    return dp[i][j]
    



t = int(input())
for test in range(t):
    n,m =[int(x) for x in input().split()]

    mat = []
    mat.append(['#' for i in range(m+2)])
    for i in range(n):
        x = ["#"]+list(input())+['#']
        mat.append(x)
    mat.append(['#' for i in range(m+2)])
   # print(mat)

    for i in range(1,n+1):
        for j in range(1,m+1):
            if mat[i][j]=='B':
                if mat[i-1][j]==".":
                    mat[i-1][j]='#'
                if mat[i+1][j]==".":
                    mat[i+1][j]='#'
                if mat[i][j-1]==".":
                    mat[i][j-1]='#'
                if mat[i][j+1]==".":
                    mat[i][j+1]='#'
    
    dp = []
    dp.append(False for i in range(m+2))
    for i in range(n):
        x = [None for i in range(m+2)]
        dp.append(x)
    dp.append(False for i in range(m+2))


    flag=0
    for i in range(1,n+1):
        for j in range(1,m+1):
            if mat[i][j]=='G':
                visited=set()
                if dfs(i,j,n,m)==False:
                    flag=1
            if mat[i][j]=='B':
                visited=set()
                if dfs(i,j,n,m)==True:
                    flag=1
    
    if flag==1:
        print("No")
    else:
        print("Yes")