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:
#
#    ------------------------------------------------
#         Fast Tests Competitive Python Template
#    ------------------------------------------------
#    Author: prophet "神"
#    Version: 1V3uJkowFG
#    License: GNU Affero General Public License v3.0
#    Location: 218.92.0.135
#    ------------------------------------------------
#

testing_mode = True

import sys, traceback

test_data = ""
final_output = ""

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for x in range(multi)]
    else:
        next_line = next(test_data, None).strip() if test_data else sys.stdin.readline()

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = next_line.split()
        elif input_format == 4: formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
        elif input_format == 5: formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
        else: formatted_input = [next_line]

        return formatted_input

def log(*args):
    if testing_mode: print(*args)

def out(output_line, output_format = 0, newline = True):

        global final_output

        formatted_output = ""

        if output_format == 0: formatted_output = str(output_line)
        elif output_format == 1: formatted_output = " ".join(map(str, output_line))
        elif output_format == 1: formatted_output = "\n".join(map(str, output_line))

        if testing_mode: final_output += formatted_output + "\n" * newline
        else: print(formatted_output, end = "\n" if newline else "")

test_inputs = [
# Input 1
"""
10
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.
4 4
GGGG
GGGG
GGGG
GGG.
4 4
B.GG
..GG
GGGG
GGG.
4 4
BGGG
..GG
GGGG
GGG.
3 4
G...
###.
B...

""",
# Input 2
"""
1
4 4
GGGG
GGGG
GGGG
GGG.
""",
# Input 3
"""
$$$
""",
# Input 4
"""
$$$
"""
]

test_outputs = [
# Output 1
"""
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes

""",
# Output 2
"""
$$$
""",
# Output 3
"""
$$$
""",
# Output 4
"""
$$$
"""
]

#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#

import collections


def getAdj(n, m, x, y):
    adj = []
    if x < m - 1:
        adj.append((x + 1, y))
    if x > 0:
        adj.append((x - 1, y))
    if y < n - 1:
        adj.append((x, y + 1))
    if y > 0:
        adj.append((x, y - 1))

    return adj

def solve():

    def s(n, m, x, y):
        nonlocal k

        if k[y][x] == "*":
            return True

        v = []
        vl = [(x, y)]

        for i in range(n):
            v.append([False] * m)

        q = collections.deque([(x, y)])
        v[y][x] = True

        found = False

        while q:
            f = q.popleft()

            adj = getAdj(n, m, f[0], f[1])
            # log(adj, k, n, m, f[0], f[1])
            for i, j in adj:
                log(i, j)
                if not v[j][i] and k[j][i] != "#":
                    if k[j][i] == "*":
                        found = True
                    q.append((i, j))
                    v[j][i] = True
                    vl.append((i, j))
                if found:
                    break
        if found:
            for i, j in vl:
                k[j][i] = "*"
            return True
        else:
            return False


    for z in range (input(1)[0]):

        n, m = input(1)

        k = []

        for i in range(n):
            k.append([x for x in input(0)[0] if x != "\n"])

        k[-1][-1] = "*"

        g = []
        b = []

        for i, r in enumerate(k):
            for j, c in enumerate(r):
                if c == "G":
                    g.append((j, i))
                elif c == "B":
                    b.append((j, i))

        fail = False

        for x, y in b:

            adj = getAdj(n, m, x, y)

            for xa, ya in adj:
                if k[ya][xa] == "." or k[ya][xa] == "*" :
                    k[ya][xa] = "#"
                elif k[ya][xa] == "G":
                    fail = True
                    break

        for i in k:
            log(i)
        log()

        if fail:
            out("No")
        else:
            for x, y in g:
                if not s(n, m, x, y):
                    out("No")
                    break
                for i in k:
                    log(i)
                log()
            else:
                out("Yes")

        log()

    return

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#

def run_all(overwrite_testing = False):

    global testing_mode, final_output, test_data

    testing_mode = overwrite_testing and testing_mode

    if testing_mode:

        tests_failed = 0

        for test_number, (test_in, test_out) in enumerate(zip(test_inputs, test_outputs)):

            final_output = ""

            if test_in.lstrip()[:3] == "$$$": continue

            test_data = iter([i for i in test_in.split("\n") if i])

            print(f"Test Case #{test_number + 1}:")
            print("<" * 20)

            fail = False
            verdict = "\033[92m\033[1mPASS\033[0m"

            try:
                solve()
                final = final_output.rstrip("\n")
                raw_out = iter(map(str, final.split("\n"))) if final else iter(())
            except Exception:
                raw_out = ""
                fail = True
                print("\033[95m")
                traceback.print_exc()
                print("\033[0m")

            if raw_out:
                if test_out.lstrip()[:3] == "$$$":
                    verdict = "\033[94m\033[1mSKIP\033[0m"
                    print("\033[94m" + '\n'.join(list(raw_out)) + "\033[0m")
                else:
                    for line_out in [i for i in test_out.split("\n") if i]:
                        line_raw = next(raw_out, "% None %")
                        if line_raw == line_out.strip():
                            print(f"\033[92m{line_raw}\033[0m")
                        else:
                            print(f"\033[91m{line_raw}\033[0m")
                            fail = True

                    line_raw = next(raw_out, None)
                    while line_raw:
                        print(f"\033[91m{line_raw}\033[0m")
                        line_raw = next(raw_out, None)
                        fail = True

            print(">" * 20)

            if fail:
                verdict = "\033[91m\033[1mFAIL\033[0m"
                tests_failed += 1

            print(verdict + "\n")

        if tests_failed: print(f"\033[91m\033[1m{tests_failed} TEST{'S' if tests_failed > 1 else ''} FAILED!\033[0m")
        else: print(f"\033[92m\033[1mALL TESTS PASSED!\033[0m")

    else:

        test_data = False
        solve()

run_all(0)