import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = int(1e9)+7
#from decimal import Decimal

def main():


    for t in range(int(data())):
        n,m=mdata()
        mat=[]
        dp = [[0] * m for i in range(n)]
        steps = [(0,1),(0,-1),(1,0),(-1,0)]
        for i in range(n):
            mat.append(data())
        for i in range(n):
            for j in range(m):
                if mat[i][j]=='B':
                    for a,b in steps:
                        if 0<=i+a<n and 0<=j+b<m:
                            dp[i+a][j+b]=-1
                    dp[i][j]=-1
                if mat[i][j] == '#':
                    dp[i][j]=-1
        s=[]
        if dp[-1][-1]!=-1:
            dp[-1][-1]=1
            s=[[n-1,m-1]]
        while s:
            i,j=s.pop()
            for a, b in steps:
                if 0 <= i + a < n and 0 <= j + b < m:
                    if dp[i + a][j + b] == 0:
                        dp[i+a][j+b] = 1
                        s.append([i+a,j+b])
        flag=True
        for i in range(n-1,-1,-1):
            for j in range(m-1,-1,-1):
                if mat[i][j]=='G' and dp[i][j]!=1:
                    flag=False
                    break
            if flag==False:
                break
        if flag==False:
            out("No")
        else:
            out("Yes")



if __name__ == '__main__':
    main()