t = int(input())
while t>0:
    t-=1
    n,m = map(int,input().strip().split(" "))
    arr = []
    for i in range(n):
        arr.append(list(input().strip()))
    
    row = [0,0,1,-1]
    col = [1,-1,0,0]
    
    for i in range(n):
        for j in range(m):
            if arr[i][j] == 'B':
                for k in range(4):
                    a = i+row[k]
                    b = j+col[k]
                    if a>=0 and a<n and b>=0 and b<m:
                        if arr[a][b] == '.':
                            arr[a][b] = '#'
    
    queue = []
    visited = [[False for i in range(m+1)] for j in range(n+1)]
    if arr[n-1][m-1] == '.':
        queue.append([n-1,m-1])
        visited[n-1][m-1] = True
    
    while queue:
        curr = queue.pop(0)
        
        for i in range(4):
            a = curr[0]+row[i]
            b = curr[1]+col[i]
            if a>=0 and a<n and b>=0 and b<m:
                if arr[a][b] != '#' and not visited[a][b]:
                    queue.append([a,b])
                    visited[a][b] = True
                    
    ans = True
    for i in range(n):
        for j in range(m):
            if arr[i][j]=='B' and visited[i][j]:
                ans = False
            elif arr[i][j] == 'G' and not visited[i][j]:
                ans = False
                
    if ans:
        print("Yes")
    else:
        print("No")
    