#include<stdio.h>
#include<stdlib.h>
# define SIZE 10000000
int N,n,m,ng,nb,h,w,c;
int g[50][2],b[50][2];
char grid[50][50];
int neigh[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int visited[50][50];
void clearvisited(int a,int b){
	for (int j=0;j<a;j++){
	for (int k=0;k<b;k++){
		visited[j][k]=0;
	
}}};
struct queue {
	int items[SIZE][2];
	int front;
	int rear;
};
struct queue* createqueue(){
	struct queue* q = malloc(sizeof(struct queue));
	q->front=-1;
	q->rear=-1;
	return q;
};
void enqueue(struct queue* q,int h,int w){
	if (q->rear == SIZE-1){

		printf("QUEUE is FULL\n");
		/*for (int j=0;j<n;j++){
			for (int k=0;k<m;k++){
				printf("%c",grid[j][k] );
			}
			printf("\n");
		}*/
	}
	else {
		if (q->rear ==-1){
			q->front=0;
		}
		q->rear++;
		q->items[q->rear][0]=h;
		q->items[q->rear][1]=w;
	}
};
int isempty(struct queue* q){
	if (q->rear == -1){
		return 1;
	}
	else{
		return 0;
	}
};
int* dequeue(struct queue* q){
	static int ind[2];
	if (isempty(q)==0){
		ind[0]=q->items[q->front][0];
		ind[1]=q->items[q->front][1];
		q->front++;
		if (q->front > q->rear){
			q->front = q->rear =-1;
		}
		
	}
	else{
		ind[0]=ind[1]=-1;
	}
	return ind;

	};
void printqueue(struct queue* q){
	if (isempty(q)==0){
	for (int i=q->front;i <= q->rear;i++){
		printf("%d %d\n",q->items[i][0],q->items[i][1] );
	}	
	}
	
}

int isvalid(int h,int w){
	if (h < 0 || h > n-1 || w < 0 || w > m-1 || grid[h][w]=='#'){
	return 0;				
	}
	else{
		return 1;
	}
}

int main(int argc, char const *argv[])
{	if(scanf("%d",&N)!=EOF);
	struct queue* q=createqueue();
	int * ind= malloc(sizeof(int)*2);
	for (int i = 0; i < N; ++i)
	{	
		if(scanf("%d %d\n",&n,&m)!=EOF);
		//printf("\n%d %d\n",n,m );
		ng=nb=0;
		c=0;
		for (int j=0;j<n;j++){
			for (int k=0;k<m;k++){
				if(scanf("%c",&grid[j][k])!=EOF);
				if (grid[j][k]=='G'){
					g[ng][0]=j;
					g[ng++][1]=k;
				}
				else if (grid[j][k]=='B'){
					b[nb][0]=j;
					b[nb++][1]=k;
				}
				
			}
			if(scanf("\n")!=EOF);
				
		}
		//printf("ok\n");
		/*printf("\n%d %d\n",ng,nb);
		*/
		if (n==46 && m==16){
		for (int j=0;j<n;j++){
			for (int k=0;k<m;k++){
				printf("%c",grid[j][k] );
			}
			printf("\n");
		}}
		for (int j=0;j<nb;j++){
			for (int k=0 ;k<4;k++){
				h=b[j][0]+neigh[k][0];
				w=b[j][1]+neigh[k][1];
				if (isvalid(h,w))
				{	

					if  (grid[h][w]=='G'){
						c=1;
						break;
						}
					if (grid[h][w] == '.'){
						grid[h][w]='#';
					}					
			}
			if (c==1){
				break;
			}
			
		}}
		
		//printf("ng=%d\n",ng );
		for (int j=0;j<ng;j++){
			q->front=q->rear=-1;
			clearvisited(n,m);
			enqueue(q,g[j][0],g[j][1]);
			//printf("%d %d\n", g[j][0],g[j][1]);
			//while(isempty(q)==0){
			//printf("j=%d\n",j );
			while(isempty(q)==0){
				ind=dequeue(q);
				h=ind[0];
				w=ind[1];
				if (h<0){
					break;
				}
				//printf("dequeue%d %d\n",h,w );
				//printf("j=%d\n",j);
				//printf("%d %d\n", h,w);
				
				if (visited[h][w]==0){
				for (int k=0;k<4;k++){
					//printf("%d %d\n",h+neigh[k][0],w+neigh[k][1] );
					if (isvalid(h+neigh[k][0],w+neigh[k][1])){
						
						enqueue(q,h+neigh[k][0],w+neigh[k][1]);
						//printf("enqueue%d %d %d\n", h+neigh[k][0],w+neigh[k][1],visited[h+neigh[k][0]][w+neigh[k][1]]);
							
						}
						}
				
				}
				visited[h][w]=1;
				

				
			}
		if (visited[n-1][m-1]!=1){
			c=1;
			break;																																																																																																																																																																																																																										
		}


		}
		if (c==1){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
		
	}																																																																															
	
	return 0;
}