from collections import deque
inp = lambda: map(int, input().split())

ts, = inp()

char_map = {"#":-1,".":0, "G":1, "B": 2}

for _ in range(ts):
    m, n = inp()
    g_pos = set()

    arr = [[0]*n for i in range(m)]
    for i in range(m):
        row = input() 
        for j in range(n):
            arr[i][j] = char_map[row[j]]
            if row[j] == "G":
                g_pos.add((i,j))

    if len(g_pos) == 0 :
        print("yes")
        continue
    
    for i in range(m):
        for j in range(n):
            if arr[i][j] == 2:
                if i < m-1:
                    arr[i+1][j] = -1
                if i> 0 : 
                    arr[i-1][j] = -1
                if j< n-1:
                    arr[i][j+1] = -1
                if j> 0:
                    arr[i][j-1] = -1

    if arr[m-1][n-1] == -1:
        print("no")
        continue

    q = deque()

    q.append((m-1,n-1))
    seen = set()

    while q:
        i, j = q.popleft()
        
        if (i,j) not in seen:
            seen.add((i,j))

        if i>0 and arr[i-1][j] != -1 and (i-1,j) not in seen:
            q.append((i-1,j))
        
        if j >0 and arr[i][j-1] != -1 and (i,j-1) not in seen:
            q.append((i,j-1))

    # print("l"*10)
    # print(arr)
    if seen.intersection(g_pos) == g_pos:
        print("yes")
    else:
        # print("l"*10)
        # print(arr)
        # print(seen.intersection(g_pos), g_pos)
        print("no")
            




    



