def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    t = int(input())
    for _ in range(t):
        N, M = [int(x) for x in input().strip().split()]
        g = [0] * N
        for n in range(N):
            g[n] = list(input().strip())
            # print(g[n])

        if g[N-1][M-1] == '#' or g[N-1][M-1] == 'B':
            print('No')
            continue

        def killBadBoys(n, m):
            q = [(n, m)]
            g[n][m] = '#'
            while q:
                n, m = q.pop()
                if n - 1 >= 0:
                    if g[n-1][m] == '.':
                        g[n-1][m] = '#'
                    elif g[n-1][m] == 'B':
                        g[n-1][m] = '#'
                        q.append((n-1, m))
                    elif g[n-1][m] == 'G':
                        return False
                if m - 1 >= 0:
                    if g[n][m-1] == '.':
                        g[n][m-1] = '#'
                    elif g[n][m-1] == 'B':
                        g[n][m-1] = '#'
                        q.append((n, m-1))
                    elif g[n][m-1] == 'G':
                        return False
                if n + 1 < N:
                    if g[n+1][m] == '.':
                        g[n+1][m] = '#'
                    elif g[n+1][m] == 'B':
                        g[n+1][m] = '#'
                        q.append((n+1, m))
                    elif g[n+1][m] == 'G':
                        return False
                if m + 1 < M:
                    if g[n][m+1] == '.':
                        g[n][m+1] = '#'
                    elif g[n][m+1] == 'B':
                        g[n][m+1] = '#'
                        q.append((n, m+1))
                    elif g[n][m+1] == 'G':
                        return False
            else:
                return True
                        
        for n in range(N):
            f = True
            for m in range(M):
                if g[n][m] == 'B':
                    if killBadBoys(n, m):
                        continue
                    else:
                        f = False
                        break
            if not f:
                break
        # for n in range(N):
        #     print(g[n])

        if not f:
            print('No')
            continue

        if g[N-1][M-1] == '.':
            q = [(N-1, M-1)]
            g[N-1][M-1] = '#'
        else:
            q = []
        while q:
            n, m = q.pop()
            if n - 1 >= 0:
                if g[n-1][m] == '.':
                    g[n-1][m] = '#'
                    q.append((n-1, m))
                elif g[n-1][m] == 'G':
                    g[n-1][m] = '#'
                    q.append((n-1, m))
            if m - 1 >= 0:
                if g[n][m-1] == '.':
                    g[n][m-1] = '#'
                    q.append((n, m-1))
                elif g[n][m-1] == 'G':
                    g[n][m-1] = '#'
                    q.append((n, m-1))
            if n + 1 < N:
                if g[n+1][m] == '.':
                    g[n+1][m] = '#'
                    q.append((n+1, m))
                elif g[n+1][m] == 'G':
                    g[n+1][m] = '#'
                    q.append((n+1, m))
            if m + 1 < M:
                if g[n][m+1] == '.':
                    g[n][m+1] = '#'
                    q.append((n, m+1))
                elif g[n][m+1] == 'G':
                    g[n][m+1] = '#'
                    q.append((n, m+1))

        # for n in range(N):
        #     print(g[n])
        f = True
        for n in range(N):
            for m in range(M):
                if g[n][m] == 'B' or g[n][m] == 'G':
                    f = False
                    break
            if not f:
                break
        else:
            print('Yes')
            continue
        print('No')


if __name__ == '__main__':
    main()