from sys import stdin,stdout
from collections import deque
def main():
    for t in range(int(stdin.readline())):
        n,m=map(int,stdin.readline().split())
        a=[]
        g=[]
        for i in range(n):
            a.append(list(stdin.readline().strip()))
        for i in range(n):
            for j in range(m):
                if a[i][j] == 'B':
                    if i!=0:
                        if a[i-1][j]=='.':
                            a[i-1][j]='#'
                    if i!=n-1:
                        if a[i+1][j]=='.':
                            a[i+1][j]='#'
                    if j!=0:
                        if a[i][j-1]=='.':
                            a[i][j-1]='#'
                    if j!=m-1:
                        if a[i][j+1]=='.':
                            a[i][j+1]='#'
                elif a[i][j]=="G":
                    g.append([i,j])
        z=len(g)
        if z==n*m-1 or z==0:
            stdout.write("Yes\n")
            continue
        ans="Yes"
        visited = set()
        for i in g:
            flag=0
            final=0
            q = deque()
            q.appendleft(i)
            while q:
                b = q.pop()
                u = b[0]
                v = b[1]
                if (u * m + v + 1) in visited:
                    final = 1
                    continue
                else:
                    visited.add(u * m + v + 1)
                if u == n - 1 and v == m - 1:
                    final = 1
                    break
                if u != n - 1:
                    if a[u + 1][v] == '.' or a[u + 1][v] == 'G':
                        q.appendleft([u + 1, v])
                    elif a[u + 1][v] == "B":
                        flag = 1
                        break
                if u != 0:
                    if a[u - 1][v] == '.' or a[u - 1][v] == 'G':
                        q.appendleft([u - 1, v])
                    elif a[u - 1][v] == 'B':
                        flag = 1
                        break
                if v != 0:
                    if a[u][v - 1] == '.' or a[u][v - 1] == 'G':
                        q.appendleft([u, v - 1])
                    elif a[u][v - 1] == 'B':
                        flag = 1
                        break
                if v != m - 1:
                    if a[u][v + 1] == '.' or a[u][v + 1] == 'G':
                        q.appendleft([u, v + 1])
                    elif a[u][v + 1] == 'B':
                        flag = 1
                        break
            if flag==1 or final==0:
                ans="No"
                break
        #print(a)
        #print(g)
        #print(visited)
        stdout.write(ans+"\n")
if __name__=="__main__":
    main()