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 dp[n - 1][m - 1] == '#':
        print("No")
        continue
    a = []
    b = []
    a.append((n - 1, m - 1))
    while len(a) != 0:
        b = []
        for i in range(len(a)):
            c = a[i][0]
            d = a[i][1]
            if c + 1 < n and d < m and dp[c + 1][d] == 1 and mat[c + 1][d] != '#':
                b.append((c + 1, d))
                dp[c + 1][d] = 0
            if c < n and d + 1 < m and dp[c][d + 1] == 1 and mat[c][d + 1] != '#':
                b.append((c, d + 1))
                dp[c][d + 1] = 0
            if c - 1 >= 0 and d < m and dp[c - 1][d] == 1 and mat[c - 1][d] != '#':
                b.append((c - 1, d))
                dp[c - 1][d] = 0
            if c >= 0 and d - 1 >= 0 and dp[c][d - 1] == 1 and mat[c][d - 1] != '#':
                b.append((c, d - 1))
                dp[c][d - 1] = 0
        a=b+[]
        b=[]
    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")
