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]='#'
    
    que = []
    dp = [[False for i in range(m+2)] for j in range(n+2)]
    if mat[n][m]=='.':
        que.append((n,m))
        dp[n][m]=True

    while len(que)>0:
        x = que.pop()
        i = x[0]
        j = x[1]
        if (i-1)>=0 and dp[i-1][j]==False and mat[i-1][j]!='#':

            que.append((i-1,j))
            dp[i-1][j]=True

        if (i+1)<=n and dp[i+1][j]==False and mat[i+1][j]!='#':
            que.append((i+1,j))
            dp[i+1][j]=True
        if (j-1)>=0 and dp[i][j-1]==False and mat[i][j-1]!='#':
            que.append((i,j-1))
            dp[i][j-1]=True
        if (j+1)<=m and dp[i][j+1]==False and mat[i][j+1]!='#':
            que.append((i,j+1))
            dp[i][j+1]=True
    flag=0
    for i in range(1,n+1):
        for j in range(1,m+1):
            if (mat[i][j]=='G' and dp[i][j]==False) or (mat[i][j]=='B' and dp[i][j]==True):
                flag=1
                break
        

    if flag==1:
        print("No")
    else:
        print("Yes")