def isValid(i,j,n,m,table,visited):
    if(i>=0 and j>=0 and i<n and j<m and table[i][j]!="#" and visited[i][j]==0):
        return True
    else:
        return False
t = int(input())
for i in range(t):
    n,m = map(int,input().split())
    table=[]
    for i in range(n):
        arr = list(input())
        table.append(arr)
    for i in range(n):
        for j in range(m):
            if(table[i][j]=="B"):
                if(i+1<n and table[i+1][j]=="."):
                    table[i+1][j]="#"
                if(i-1>=0 and table[i-1][j]=="."):
                    table[i-1][j]="#"
                if(j+1<m and table[i][j+1]=="."):
                    table[i][j+1]="#"
                if(j-1>=0 and table[i][j-1]=="."):
                    table[i][j-1]="#"
    visited = []
    for i in range(n):
        visited.append([0] * m)
    q=[]
    q.append([n-1,m-1])
    visited[n-1][m-1]=1
    while(len(q)!=0):
        front = q.pop(0)
        (i,j) = front
        if(isValid(i-1,j,n,m,table,visited)):
            q.append([i-1,j])
            visited[i-1][j]=1
        if(isValid(i+1,j,n,m,table,visited)):
            q.append([i+1,j])
            visited[i+1][j]=1
        if(isValid(i,j-1,n,m,table,visited)):
            q.append([i,j-1])
            visited[i][j-1]=1
        if(isValid(i,j+1,n,m,table,visited)):
            q.append([i,j+1])
            visited[i][j+1]=1

    flag = True
    if(table[n-1][m-1]!="#"):
        for i in range(n):
            for j in range(m):
                if(table[i][j]=="G" and visited[i][j]==0):
                    flag=False
                    break
                if(table[i][j]=="B" and visited[i][j]==1):
                    flag=False
                    break
            if(flag==False):
                break
    else:
        for i in range(n):
            for j in range(m):
                if(table[i][j]=="G"):
                    flag=False
                    break
            if(flag==False):
                break
    if(flag):
        print("Yes")
    else:
        print("No")


