t = int(input())
for tc in range(t):
    n, m = [int(x) for x in input().split()]
    mat = []
    for i in range(n):
        s = list(input())
        mat.append(s)
    count = 0
    b = 0
    for i in range(n):
        for j in range(m):
            if mat[i][j] == 'G':
                count += 1
    if count == 0:
        print("Yes")
        continue
    for i in range(n):
        for j in range(m):
            if mat[i][j] == 'B':
                if i + 1 < n:
                    if mat[i + 1][j] == '.':
                        mat[i + 1][j] = '#'
                if i - 1 >= 0:
                    if mat[i - 1][j] == '.':
                        mat[i-1][j] = '#'
                if j - 1 >= 0:
                    if mat[i][j - 1] == '.':
                        mat[i][j - 1] = '#'
                if j + 1 < m:
                    if mat[i][j + 1] == '.':
                        mat[i][j + 1] = '#'
    dp = [[1 for i in range(m)] for j in range(n)]
    if mat[n - 1][m - 1] == '.':
        dp[n - 1][m - 1] = 0
    for i in range(n - 1, -1, -1):
        for j in range(m - 1, -1, -1):
            if i + 1 < n and j < m:
                if mat[i + 1][j] != '#' and dp[i + 1][j] == 0:
                    dp[i][j] = 0
            if i < n and j + 1 < m:
                if mat[i][j + 1] != '#' and dp[i][j + 1] == 0:
                    dp[i][j] = 0
    flag = 0
    for i in range(n):
        for j in range(m):
            if mat[i][j] == 'G' and dp[i][j] == 1:
                flag = 1
                break
            if mat[i][j] == 'B' and dp[i][j] == 0:
                flag = 1
                break
    if flag == 1:
        print("No")
    else:
        print("Yes")
