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:
# -*- coding: utf-8 -*-
from collections import defaultdict
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)
        self.__rank = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x == y:
            return False

        if self.__rank[x] < self.__rank[y]:
            self.__table[x] = y
            self.__size[y] += self.__size[x]
        else:
            self.__table[y] = x
            self.__size[x] += self.__size[y]
            if self.__rank[x] == self.__rank[y]:
                self.__rank[x] += 1
        return True

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g



# @mt
def slv(N, M, G):
    G = [[ c for c in r] for r in G]
    # print(G)

    for i in range(N):
        for j in range(M):
            if G[i][j] == 'B':
                if i > 0:
                    if G[i-1][j] == 'G':
                        return 'No'
                    elif G[i-1][j] != 'B':
                        G[i-1][j] = '#'
                if i < N-1:
                    if G[i+1][j] == 'G':
                        return 'No'
                    elif G[i+1][j] != 'B':
                        G[i+1][j] = '#'
                if j > 0:
                    if G[i][j-1] == 'G':
                        return 'No'
                    elif G[i][j-1] != 'B':
                        G[i][j-1] = '#'
                if j < M-1:
                    if G[i][j+1] == 'G':
                        return 'No'
                    elif G[i][j+1] != 'B':
                        G[i][j+1] = '#'
    uf = UnionFind()
    g = (N-1, M-1)
    q = [g]
    done = set()
    done.add(g)
    while q:
        i, j = q.pop()
        for dx, dy in [(-1, 0), (0, -1), (0, 1), (1, 0)]:
            x = i + dx
            y = j + dy
            if (x, y) in done:
                continue
            if 0 <= x < N and 0 <= y < M and G[x][y] != '#':
                uf.union(g, (x, y))
                q.append((x, y))
                done.add((x, y))

    gc = 0
    for i in range(N):
        for j in range(M):
            if G[i][j] == 'G':
                if not uf.same(g, (i, j)):
                    return 'No'
                gc += 1

    if gc > 0 and G[N-1][M-1] == '#' or G[N-1][M-1] == 'B':
        return 'No'
    return 'Yes'
    # print(G)



    # for i in range(1, N):

    # k = [[], []]
    # for a, b in zip(A, B):
    #     k[b].append(a)
    # if tuple(k[0]) == tuple(sorted(k[0])) and tuple(k[1]) == tuple(sorted(k[1])):
    #     return 'Yes'
    # return 'No'


def main():
    T = read_int()
    for _ in range(T):
        N, M = read_int_n()
        G = [read_str() for _ in range(N)]
        print(slv(N, M, G))


if __name__ == '__main__':
    main()