def dfs(i,j, visited):
    if l[i][j]=="#":
        return visited
    visited[(i,j)] = True
    for k in range(0,2):
        if l[i+k][j+1-k]!='#' and (i+k, j+1-k) not in visited:
            visited = dfs(i+k,j+1-k, visited)
        if l[i-k][j-1+k]!='#' and (i-k, j-1+k) not in visited:
            visited = dfs(i-k,j-1+k, visited)
    return visited
for t in range(int(input())):
    # n = int(input())
    n,m = [int(j) for j in input().split()]
    l = []
    for i in range(n):
        l.append(["#"]+list(input())+["#"])
    l = [["#" for i in range(m+2)]]+l+[["#" for i in range(m+2)]]
    # print(l)
    flag = True
    for i in range(1,n+1):
        for j in range(1,m+1):
            if l[i][j]=='B':
                for k in range(0,2):
                    if l[i+k][j+1-k]=='G' or l[i-k][j-1+k]=='G':
                        flag = False
                l[i][j]="#"
                for k in range(0,2):
                    # print()
                    l[i+k][j+1-k]='#'
                    l[i-k][j-1+k]='#'
    # print(l)
    visited = dict()
    visited = dfs(n,m, visited)
    for i in range(1,n+1):
        for j in range(1,m+1):
            if l[i][j]=='G':
                if (i,j) not in visited:
                    flag = False
    if flag:
        print("Yes")
    else:
        print("No")





