import string
cnt = 0
dfs = [[0] * 200] * 200
def DFS(i, j):
    global cnt
    if(dfs[i][j] == 1):
        return
    else:
        dfs[i][j] = 1
        if(a[i][j] == 'G'):
            cnt += 1
        if(a[i][j] == '#'):
            return
        if(i > 0):
            DFS(i - 1, j)
        if(i < n - 1):
            DFS(i + 1, j)
        if(j > 0):
            DFS(i, j - 1)
        if(j < m - 1):
            DFS(i, j + 1)
for _ in range(int(input())):
    inp = list(map(int,input().split()))
    n = inp[0]
    m = inp[1]
    a = [0] * 200
    flag = False
    dfs = []
    cnt2 = 0
    cnt = 0
    for i in range(n):
        a[i] = input()
    for i in range(n):
        dfs.append([])
        for j in range(m):
            dfs[i].append(0)
            if a[i][j] == 'G':
                cnt2 += 1
            if a[i][j] == 'B':
                if i < n - 1:
                    if (a[i + 1][j] == 'G'):
                        flag = True
                if i > 0:
                    if (a[i - 1][j] == 'G'):
                        flag = True
                if j < m - 1:
                    if (a[i][j + 1] == 'G'):
                        flag = True
                if j > 0:
                    if (a[i][j - 1] == 'G'):
                        flag = True
                if(i < n - 1) : 
                    if (a[i + 1][j] != 'B'):
                        a[i + 1] = a[i + 1][:j] + '#' + a[i + 1][j + 1:]
                if(i > 0) : 
                    if (a[i - 1][j] != 'B'):
                        a[i - 1] = a[i - 1][:j] + '#' + a[i - 1][j + 1:]
                if(j < m - 1) : 
                    if (a[i][j + 1] != 'B'):
                        a[i] = a[i][:j + 1] + '#' + a[i][j + 2:]
                if(j > 0) : 
                    if (a[i][j - 1] != 'B'):
                        a[i] = a[i][:j - 1] + '#' + a[i][j:]
    """for i in range(n):
        print(a[i])"""
    if flag:
        print("No")
        continue
    else:
        if(a[n - 1][m - 1] == '#'):
            if(cnt > 0):
                print("No")
            else:
                print("Yes")
            continue
        DFS(n - 1, m - 1)
        if cnt == cnt2:
            print("Yes")
        else:
            print("No")