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 sys
sys.setrecursionlimit(100000)
dir =[(-1, 0), (1, 0), (0, -1), (0, 1)]  #Direcciones donde se puede encontrar los adyacentes a una casilla
 
def dfs(i, j): #dfs a partir de la casilla de salida para saber si puede alcanzar a todos los G
    visited[i][j] = True#marcar la casilla como visitada
    for di, dj in dir:#Verificar las posibles direcciones
        if di+i<0 or di+i>=n or dj+j<0 or dj+j>=m:#Ver si al movernos en una direccion nos salimos del mapa
            continue
        if not visited[i + di][j + dj] and maze[i + di][j + dj] != "#":#Nos movemos para la casilla que no hayamos visitado y que no tenga una pared
            dfs(i + di, j + dj)#LLamado recursivo del dfs

t=int(input())#Obtener la cantidad de casos de prueba
for a in range(t):#Ciclo for por cada uno de los casos de prueba
    n, m = list(map(int, input().split()))#Obtenemos los valores de n y m de la entrada
    maze =[list(input())for i in range(n)]#Formamos el laberinto a partir de las lineas de entrada
    answer = True#Determina si va a ser poible o no resolver el problema
    for i in range(0, n):#Este doble for anidado nos permite recorrer cada una de las casillas
        if not answer:
            break
        for j in range(0, m ):
            if not answer:
                break
            if maze[i][j] == "B":#Verificamos si la casilla es B
                for di, dj in dir:#Verificar las posibles direcciones
                    if di+i<0 or di+i>=n or dj+j<0 or dj+j>=m:#Ver si al movernos en una direccion nos salimos del mapa
                        continue
                    if maze[i + di][j + dj] == "G":#Si en alguna direccion adyacente a dicho B hay un G entonces no es posible resolver el problema
                        answer = False
                        break
                    elif maze[i + di][j + dj] != "B":#Verifica ca la casilla este vacia para luego, si lo esta, colocar una pared
                        maze[i + di][j + dj] = "#"

    if answer:
        visited = [[False]*m for i in range(n)]#Creamos una matriz del mismo tamaño del laberinto para marcar los vertices que vayamos visitando en el dfs
        if maze[n-1][m-1] != "#":#Verifica si en la casilla de la salida colocamos una pared, en caso de que no procedemos a realizar el dfs
            dfs(n-1, m-1)
        for i in range(0, n ):#Doble for anidado que nos permite recorrer cada una de las casillas
            for j in range(0, m ):
                if maze[i][j] == "G" and not visited[i][j]:#Si existe algun vertice G que no fue visitado en el recorrido dfs entonces no es posible resolver el problema
                    answer = False
    print("Yes" if answer else "No")#Imprimimos la salida en dependencia de los resultados que almacenamos en answer.