import sys,os,io
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

for _ in range (int(input())):
    n,m = [int(i) for i in input().split()]
    grid = []
    good = 0
    for i in range (n):
        grid.append(input().strip())
    flag = 0
    for i in range (n):
        for j in range (m):
            if grid[i][j]=='G':
                good = 1
            if grid[i][j]=='B':
                if i!=0 and grid[i-1][j]=='G': flag = 1
                if i!=n-1 and grid[i+1][j]=='G': flag = 1
                if j!=m-1 and grid[i][j+1]=='G': flag = 1
                if j!=0 and grid[i][j-1]=='G': flag = 1
                if flag: break
        if flag:
            break
    if flag==0 and good == 1:
        if n>1 and grid[n-2][m-1]=='B':
            flag = 1
        if m>1 and grid[n-1][m-2]=='B':
            flag = 1
    if flag:
        print("No")
    else:
        print("Yes")