def test(n, m, a):
    Good = 0
    for i in range(n):
        for j in range(m):
            if a[i][j] == 'G':
                Good += 1
            if a[i][j] == 'B':
                if i+1 < n:
                    if a[i+1][j] == 'G':
                        return 'No'
                    elif a[i+1][j] != 'B':
                        a[i+1][j] = '#'
                if i-1 >= 0:
                    if a[i-1][j] == 'G':
                        return 'No'
                    elif a[i-1][j] != 'B':
                        a[i-1][j] = '#'
                if j+1 < m:
                    if a[i][j+1] == 'G':
                        return 'No'
                    elif a[i][j+1] != 'B':
                        a[i][j+1] = '#'
                if j-1 >= 0:
                    if a[i][j-1] == 'G':
                        return 'No'
                    elif a[i][j - 1] != 'B':
                        a[i][j-1] = '#'
    if Good == 0:
        return 'Yes'
    if a[n-1][m-1] == '#':
        return 'No'
    sosed = set()
    sosed.add((n-1, m-1))
    posetil = set()
    posetil.add((n-1, m-1))
    while len(sosed) > 0:
        sosed2 = set()
        for i in sosed:
            if a[i[0]][i[1]] == 'G':
                Good -= 1
            if i[0]+1 < n and a[i[0]+1][i[1]] != '#' and ((i[0]+1, i[1]) not in posetil):
                sosed2.add((i[0]+1, i[1]))
            if i[0]-1 >= 0 and a[i[0]-1][i[1]] != '#' and ((i[0]-1, i[1]) not in posetil):
                sosed2.add((i[0]-1, i[1]))
            if i[1]+1 < m and a[i[0]][i[1]+1] != '#' and ((i[0], i[1]+1) not in posetil):
                sosed2.add((i[0], i[1]+1))
            if i[1]-1 >= 0 and a[i[0]][i[1]-1] != '#' and ((i[0], i[1]-1) not in posetil):
                sosed2.add((i[0], i[1]-1))
        sosed = sosed2.copy()
        posetil |= sosed2
    if Good == 0:
        return 'Yes'
    else:
        return 'No'





ans = []
for kek in range(int(input())):
    (n, m) = map(int, input().split())
    a = []
    for i in range(n):
        a.append(list(input()))
    ans.append(test(n,m,a))
print(*ans,sep='\n')