
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()
                    if l[i+k][j+1-k]==".":
                        l[i+k][j+1-k]='#'
                    if l[i-k][j-1+k]=='.':
                        l[i-k][j-1+k] = "#" 
    # print(l)
    visited = dict()
    st = []
    if l[n][m]!="#":
        st.append((n,m))
    while(st):
        i,j = st.pop(0)
        for k in range(0,2):
            if l[i+k][j+1-k]!='#' and (i+k, j+1-k) not in visited:
                visited[(i+k,j+1-k)] = True
                st.append((i+k,j+1-k))
            if l[i-k][j-1+k]!='#' and (i-k, j-1+k) not in visited:
                visited[(i-k,j-1+k)] = True
                st.append((i-k,j-1+k))
    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")





