Problem: Vivek has encountered a problem. He has a maze that can be represented as an n × m grid. Each of the grid cells may represent the following:

  * Empty — '.' 
  * Wall — '#' 
  * Good person — 'G' 
  * Bad person — 'B' 



The only escape from the maze is at cell (n, m).

A person can move to a cell only if it shares a side with their current cell and does not contain a wall. Vivek wants to block some of the empty cells by replacing them with walls in such a way, that all the good people are able to escape, while none of the bad people are able to. A cell that initially contains 'G' or 'B' cannot be blocked and can be travelled through.

Help him determine if there exists a way to replace some (zero or more) empty cells with walls to satisfy the above conditions.

It is guaranteed that the cell (n,m) is empty. Vivek can also block this cell.

Input

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n, m (1 ≤ n, m ≤ 50) — the number of rows and columns in the maze.

Each of the next n lines contain m characters. They describe the layout of the maze. If a character on a line equals '.', the corresponding cell is empty. If it equals '#', the cell has a wall. 'G' corresponds to a good person and 'B' corresponds to a bad person.

Output

For each test case, print "Yes" if there exists a way to replace some empty cells with walls to satisfy the given conditions. Otherwise print "No"

You may print every letter in any case (upper or lower).

Example

Input


6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.


Output


Yes
Yes
No
No
Yes
Yes

Note

For the first and second test cases, all conditions are already satisfied.

For the third test case, there is only one empty cell (2,2), and if it is replaced with a wall then the good person at (1,2) will not be able to escape.

For the fourth test case, the good person at (1,1) cannot escape.

For the fifth test case, Vivek can block the cells (2,3) and (2,2).

For the last test case, Vivek can block the destination cell (2, 2).

Solution (in PYTHON3):

Solution:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource

# sys.setrecursionlimit(10**6)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def IF(c, t, f): return t if c else f
def YES(c): return IF(c, "YES", "NO")
def Yes(c): return IF(c, "Yes", "No")


def main():
    t = I()

    rr = []
    for _ in range(t):
        n,m = LI()
        aa = [S() for _ in range(n)]

        gs = []
        for i in range(n):
            s = aa[i]
            for j in range(m):
                if s[j] == 'G':
                    gs.append((i,j))

        ok = 1
        t = [[0]*m for _ in range(n)]
        t[-1][-1] = -1
        for i in range(n):
            if not ok:
                break
            s = aa[i]
            for j in range(m):
                c = s[j]
                if c == '.':
                    continue
                b = 0
                if c == 'G':
                    b = -1
                elif c == '#':
                    b = 1
                else: # 'B'
                    b = -1
                    for di,dj in dd:
                        ni = i + di
                        nj = j + dj
                        if ni < 0 or ni >= n or nj < 0 or nj >= m or aa[ni][nj] == 'B':
                            continue
                        if t[ni][nj] == -1:
                            ok = 0
                            break
                        t[ni][nj] = 1

                if t[i][j] * b == -1:
                    ok = 0
                    break
                t[i][j] = b

        if len(gs) < 1:
            rr.append("YES")
        elif not ok:
            rr.append("NO")
        else:
            v = collections.defaultdict(bool)
            q = [(n-1,m-1)]
            v[(n-1,m-1)] = 1
            qi = 0
            o = [[None]*m for _ in range(n)]
            while qi < len(q):
                i,j = q[qi]
                qi += 1
                o[i][j] = 1
                for di,dj in dd:
                    ni = i + di
                    nj = j + dj
                    if ni < 0 or ni >= n or nj < 0 or nj >= m or t[ni][nj] == 1 or v[(ni,nj)]:
                        continue
                    v[(ni,nj)] = 1
                    q.append((ni,nj))

            rr.append(YES(all(o[i][j] for i,j in gs)))

    return JA(rr, "\n")


print(main())