import java.io.*;
import java.util.*;

public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
static List<Pair> validated;
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int t=  sc.nextInt();
      while (t-->0) {
    	  int n = sc.nextInt();
          int m = sc.nextInt();
          List<Pair> badGuys = new ArrayList<Pair>();
          List<Pair> goodGuys = new ArrayList<Pair>();
          char[][] g = new char[n][m];
          for (int i = 0; i < n; i++){
              String s = sc.next();
              for (int j = 0; j < m; j++){
                  char c = s.charAt(j);
                  g[i][j] = c;
                  if (c == 'B'){
                      badGuys.add(new Pair(i, j));
                  }
                  else if (c == 'G'){
                        goodGuys.add(new Pair(i, j));
                  }
              }
          }
          boolean valid = true;
          // fill in all bad guys, if good guy adj bad guy fail
          for (Pair p: badGuys){
              boolean[] dir = new boolean[4];
              Arrays.fill(dir, true);
              int r = p.r;
              int c = p.c;
              if (r == 0) dir[0] = false;
              if (c == m-1) dir[1] = false;
              if (r == n-1) dir[2] = false;
              if (c == 0) dir[3] = false;
              if (dir[0]){
                  if (g[r-1][c] == 'G') valid = false;
                  if (g[r-1][c] != 'B')g[r-1][c] = '#';
              }
              if (dir[1]){
                if (g[r][c+1] == 'G') valid = false;
                  if (g[r][c+1] != 'B')g[r][c+1] = '#';

              }
              if (dir[2]){
                if (g[r+1][c] == 'G') valid = false;
                  if (g[r+1][c] != 'B')g[r+1][c] = '#';

              }
              if (dir[3]){
            if (g[r][c-1] == 'G') valid = false;
            if (g[r][c-1] != 'B')g[r][c-1] = '#';

              }
          }
        //   for (char[] cha: g){
        //       for (char c: cha){
        //           out.print(c);
        //       }
        //       out.println();
        //   }
          // for each good guy bfs to exit
          validated = new ArrayList<Pair>();
          for (Pair p: goodGuys){
              if (contains(p, validated)) continue;
              if (!search(p.r, p.c, n, m, g)) valid = false;
          }
          if (validated.size() != goodGuys.size()) valid = false;
          if (valid) out.println("YES");
          else out.println("NO");
       }

      out.close();
   }
   static boolean contains(Pair p, List<Pair> v){
       for (Pair pair: v){
           if (p.c == pair.c && p.r == pair.r) return true;
       }return false;
   }
   static boolean search(int r, int c, int n, int m, char[][] g){
       int[][] grid = new int[n][m];
       grid[r][c] = 1;
       Queue<Pair> q = new LinkedList<Pair>();
       q.add(new Pair(r, c));
       while (!q.isEmpty()){

           Pair start = q.remove();
           int val = grid[start.r][start.c];
           boolean[] dir = new boolean[4];
           Arrays.fill(dir, true);
           if (start.r == 0) dir[0] = false;
           if (start.c == m-1) dir[1] = false;
           if (start.r == n-1) dir[2] = false;
           if (start.c == 0) dir[3] = false;
            int row = start.r;
            int col = start.c;
            if (g[row][col] == 'G' && !contains(start, validated)) {
                validated.add(new Pair(row,col));
            }
           if (dir[0]){
               if (grid[row-1][col] == 0 && g[row-1][col] != '#'){
                   q.add(new Pair(row-1, col));
                   grid[row-1][col] = grid[row][col] + 1;
               }
           }
           if (dir[1]){
               if (grid[row][col+1] == 0 && g[row][col+1] != '#'){
                   q.add(new Pair(row, col+1));
                   grid[row][col+1] = grid[row][col] + 1;
               }
           }
           if (dir[2]){
               if (grid[row+1][col] == 0 && g[row+1][col] != '#'){
                   q.add(new Pair(row+1, col));
                   grid[row+1][col] = grid[row][col] + 1;
               }
           }
           if (dir[3]){
               if (grid[row][col-1] == 0 && g[row][col-1] != '#'){
                   q.add(new Pair(row, col-1));
                   grid[row][col-1] = grid[row][col] + 1;
               }
           }
       }
       return grid[g.length-1][g[0].length-1] > 0;

   }
   static class Pair{
       int r, c;
       public Pair(int x,int y){
           r=x;
           c=y;
       }
   }

   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }

   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 1) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];

      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }

      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }

      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }

    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }

      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}


import java.io.*;
import java.util.*;

public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int t=  sc.nextInt();
      while (t-->0) {
    	  int n = sc.nextInt();
          int m = sc.nextInt();
          List<Pair> badGuys = new ArrayList<Pair>();
          List<Pair> goodGuys = new ArrayList<Pair>();
          char[][] g = new char[n][m];
          for (int i = 0; i < n; i++){
              String s = sc.next();
              for (int j = 0; j < m; j++){
                  char c = s.charAt(j);
                  g[i][j] = c;
                  if (c == 'B'){
                      badGuys.add(new Pair(i, j));
                  }
                  else if (c == 'G'){
                        goodGuys.add(new Pair(i, j));
                  }
              }
          }
          boolean valid = true;
          // fill in all bad guys, if good guy adj bad guy fail
          for (Pair p: badGuys){
              boolean[] dir = new boolean[4];
              Arrays.fill(dir, true);
              int r = p.r;
              int c = p.c;
              if (r == 0) dir[0] = false;
              if (c == m-1) dir[1] = false;
              if (r == n-1) dir[2] = false;
              if (c == 0) dir[3] = false;
              if (dir[0]){
                  if (g[r-1][c] == 'G') valid = false;
                  if (g[r-1][c] != 'B')g[r-1][c] = '#';
              }
              if (dir[1]){
                if (g[r][c+1] == 'G') valid = false;
                  if (g[r][c+1] != 'B')g[r][c+1] = '#';

              }
              if (dir[2]){
                if (g[r+1][c] == 'G') valid = false;
                  if (g[r+1][c] != 'B')g[r+1][c] = '#';

              }
              if (dir[3]){
            if (g[r][c-1] == 'G') valid = false;
            if (g[r][c-1] != 'B')g[r][c-1] = '#';

              }
          }
        //   for (char[] cha: g){
        //       for (char c: cha){
        //           out.print(c);
        //       }
        //       out.println();
        //   }
          // for each good guy bfs to exit
          for (Pair p: goodGuys){
              if (!search(p.r, p.c, n, m, g)) valid = false;
          }
          if (valid) out.println("YES");
          else out.println("NO");
       }

      out.close();
   }
   static boolean search(int r, int c, int n, int m, char[][] g){
       int[][] grid = new int[n][m];
       grid[r][c] = 1;
       Queue<Pair> q = new LinkedList<Pair>();
       q.add(new Pair(r, c));
       while (!q.isEmpty()){
           Pair start = q.remove();
           int val = grid[start.r][start.c];
           boolean[] dir = new boolean[4];
           Arrays.fill(dir, true);
           if (start.r == 0) dir[0] = false;
           if (start.c == m-1) dir[1] = false;
           if (start.r == n-1) dir[2] = false;
           if (start.c == 0) dir[3] = false;
            int row = start.r;
            int col = start.c;
           if (dir[0]){
               if (grid[row-1][col] == 0 && g[row-1][col] != '#'){
                   q.add(new Pair(row-1, col));
                   grid[row-1][col] = grid[row][col] + 1;
               }
           }
           if (dir[1]){
               if (grid[row][col+1] == 0 && g[row][col+1] != '#'){
                   q.add(new Pair(row, col+1));
                   grid[row][col+1] = grid[row][col] + 1;
               }
           }
           if (dir[2]){
               if (grid[row+1][col] == 0 && g[row+1][col] != '#'){
                   q.add(new Pair(row+1, col));
                   grid[row+1][col] = grid[row][col] + 1;
               }
           }
           if (dir[3]){
               if (grid[row][col-1] == 0 && g[row][col-1] != '#'){
                   q.add(new Pair(row, col-1));
                   grid[row][col-1] = grid[row][col] + 1;
               }
           }
       }
       return grid[g.length-1][g[0].length-1] > 0;

   }
   static class Pair{
       int r, c;
       public Pair(int x,int y){
           r=x;
           c=y;
       }
   }

   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }

   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 1) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];

      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }

      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }

      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }

    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }

      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}


import java.io.*;
import java.util.*;

public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int t=  sc.nextInt();
      while (t-->0) {
    	  int n = sc.nextInt();
          int m = sc.nextInt();
          List<Pair> badGuys = new ArrayList<Pair>();
          List<Pair> goodGuys = new ArrayList<Pair>();
          char[][] g = new char[n][m];
          for (int i = 0; i < n; i++){
              String s = sc.next();
              for (int j = 0; j < m; j++){
                  char c = s.charAt(j);
                  g[i][j] = c;
                  if (c == 'B'){
                      badGuys.add(new Pair(i, j));
                  }
                  else if (c == 'G'){
                        goodGuys.add(new Pair(i, j));
                  }
              }
          }
          boolean valid = true;
          // fill in all bad guys, if good guy adj bad guy fail
          for (Pair p: badGuys){
              boolean[] dir = new boolean[4];
              Arrays.fill(dir, true);
              int r = p.r;
              int c = p.c;
              if (r == 0) dir[0] = false;
              if (c == m-1) dir[1] = false;
              if (r == n-1) dir[2] = false;
              if (c == 0) dir[3] = false;
              if (dir[0]){
                  if (g[r-1][c] == 'G') valid = false;
                  if (g[r-1][c] != 'B')g[r-1][c] = '#';
              }
              if (dir[1]){
                if (g[r][c+1] == 'G') valid = false;
                  if (g[r][c+1] != 'B')g[r][c+1] = '#';

              }
              if (dir[2]){
                if (g[r+1][c] == 'G') valid = false;
                  if (g[r+1][c] != 'B')g[r+1][c] = '#';

              }
              if (dir[3]){
            if (g[r][c-1] == 'G') valid = false;
            if (g[r][c-1] != 'B')g[r][c-1] = '#';

              }
          }
        //   for (char[] cha: g){
        //       for (char c: cha){
        //           out.print(c);
        //       }
        //       out.println();
        //   }
          // for each good guy bfs to exit

              if (!search(goodGuys, n, m, g)) valid = false;
          if (g[n-1][m-1] == '#' && goodGuys.size() > 0) valid = false;
          if (valid) out.println("YES");
          else out.println("NO");
       }

      out.close();
   }

   static boolean search(List<Pair> goodGuys, int n, int m, char[][] g){
       int pairsFound = 0;
       int[][] grid = new int[n][m];
       grid[n-1][m-1] = 1;
       Queue<Pair> q = new LinkedList<Pair>();
       q.add(new Pair(n-1, m-1));
       while (!q.isEmpty()){

           Pair start = q.remove();
           int val = grid[start.r][start.c];
           boolean[] dir = new boolean[4];
           Arrays.fill(dir, true);
           if (start.r == 0) dir[0] = false;
           if (start.c == m-1) dir[1] = false;
           if (start.r == n-1) dir[2] = false;
           if (start.c == 0) dir[3] = false;
            int row = start.r;
            int col = start.c;
            if (g[row][col] == 'G' ) {
                pairsFound++;
            }
           if (dir[0]){
               if (grid[row-1][col] == 0 && g[row-1][col] != '#'){
                   q.add(new Pair(row-1, col));
                   grid[row-1][col] = grid[row][col] + 1;
               }
           }
           if (dir[1]){
               if (grid[row][col+1] == 0 && g[row][col+1] != '#'){
                   q.add(new Pair(row, col+1));
                   grid[row][col+1] = grid[row][col] + 1;
               }
           }
           if (dir[2]){
               if (grid[row+1][col] == 0 && g[row+1][col] != '#'){
                   q.add(new Pair(row+1, col));
                   grid[row+1][col] = grid[row][col] + 1;
               }
           }
           if (dir[3]){
               if (grid[row][col-1] == 0 && g[row][col-1] != '#'){
                   q.add(new Pair(row, col-1));
                   grid[row][col-1] = grid[row][col] + 1;
               }
           }
       }
        return pairsFound == goodGuys.size();
   }
   static class Pair{
       int r, c;
       public Pair(int x,int y){
           r=x;
           c=y;
       }
   }

   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }

   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 1) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];

      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }

      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }

      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }

    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }

      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int nextInt() {
          return Integer.parseInt(next());
      }

      long nextLong() {
          return Long.parseLong(next());
      }

      double nextDouble() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Stack;

public class D {
	//author: Nagabhushan S Baddi

	private static int n, m;
	private static char[][] a;
	private static int d;
	private static String s;
	private static HashMap<Integer, ArrayList<Integer>> g;

	public static void main(String[] args) {
		int t = ini();
		while (t-- > 0) {
			n = ini();
			m = ini();
			a = new char[n][m];
			for(int i=0; i<n; i++) {
				a[i] = ins().toCharArray();
			}

			Stack<int[]> stack = new Stack<>();

			boolean[][] mark = new boolean[n][m];

			boolean[][] block = new boolean[n][m];

			int[] dx = {1, -1, 0, 0};
			int[] dy = {0, 0, -1, 1};

			stack.push(new int[] {n-1, m-1});
			mark[n-1][m-1] = true;

			while(!stack.isEmpty()) {
				int[] node = stack.pop();
				int x = node[0];
				int y = node[1];
				for(int k=0; k<4; k++) {
					int nx = x+dx[k];
					int ny = y+dy[k];
					if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
					stack.push(new int[] {nx, ny});
					mark[nx][ny] = true;
				}
			}

			boolean escape = false;

			boolean whiteEscape = true;

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]=='G' && !mark[i][j]) {
						whiteEscape = false;
					}
					if (a[i][j]=='B' && mark[i][j]) {
						escape = true;
					}
				}
			}

			if (!whiteEscape) {
				println("No");
				continue;
			}
			if (!escape) {
				println("Yes");
				continue;

			}

//			println("HEY");

			outer:
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]!='.') continue;
					for(int x=0; x<n; x++) Arrays.fill(mark[x], false);

//
//					if (i==n-1 && j==m-1) continue;

					if (!(i==n-1 && j==m-1)) {
						stack.push(new int[] {n-1, m-1});
						mark[n-1][m-1] = true;
					}

					while(!stack.isEmpty()) {
						int[] node = stack.pop();
						int x = node[0];
						int y = node[1];
						for(int k=0; k<4; k++) {
							int nx = x+dx[k];
							int ny = y+dy[k];
							if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
							stack.push(new int[] {nx, ny});
							mark[nx][ny] = true;
						}
					}

					boolean canBe = true;

					boolean blackWidow = false;

					out:
					for(int x=0; x<n; x++) {
						for(int y=0; y<m; y++) {
							if (a[x][y]=='G' && !mark[x][y]) {
								canBe = false;
								break out;
							}
							if (a[x][y]=='B' && mark[x][y]) {
								blackWidow = true;
							}
						}
					}

//					System.out.println(i+" "+j+" "+canBe);

					if (!canBe) continue;

//					whiteEscape = true;

					block[i][j] = true;
					escape = blackWidow;
					if (!blackWidow) {
						break outer;
					}
				}

			}

			println(!escape?"Yes":"No");
		}

		out.flush();
		out.close();

	}

	//CONSTANTS
	private static final int MOD = (int) 1e9 + 7;

	//NONPROBLEM CODE

	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	//SORT SHORTCUTS

	private static void sort(int[] a) {
		int n = a.length;
		Integer[] b = new Integer[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	private static void sort(long[] a) {
		int n = a.length;
		Long[] b = new Long[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	//INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	private static long inl() {
		return in.nextLong();
	}

	private static String ins() {
		return in.readString();
	}

	//PRINT SHORTCUTS

	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.write("\n");
	}

	private static void pd(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.flush();
		out.write("\n");
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
	}

	//GRAPH SHORTCUTS

	private static HashMap<Integer, ArrayList<Integer>> intree(int n) {

		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();
		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;
	}

	private static HashMap<Integer, ArrayList<Integer>> ingraph(int n, int m) {
		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;

	}

	private static HashMap<Integer, ArrayList<Edge>> inweightedgraph(int n, int m) {
		HashMap<Integer, ArrayList<Edge>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			int w = ini();
			Edge edge = new Edge(u, v, w);
			g.get(u).add(edge);
			g.get(v).add(edge);
		}

		return g;

	}

	private static class Edge implements Comparable<Edge> {
		private int u, v;
		private long w;

		public Edge(int a, int b, long c) {
			u = a;
			v = b;
			w = c;
		}

		public int other(int x) {
			return (x == u ? v : u);
		}

		public int compareTo(Edge edge) {
			return Long.compare(w, edge.w);
		}
	}

	private static class Pair {
		private int u, v;

		public Pair(int a, int b) {
			u = a;
			v = b;
		}

		public int hashCode() {
			return u + v + u * v;
		}

		public boolean equals(Object object) {
			Pair pair = (Pair) object;
			return u == pair.u && v == pair.v;
		}
	}

	private static class Node implements Comparable<Node> {
		private int u;
		private long dist;

		public Node(int a, long b) {
			u = a;
			dist = b;
		}

		public int compareTo(Node node) {
			return Long.compare(dist, node.dist);
		}
	}

	//MATHS AND NUMBER THEORY SHORTCUTS

	private static int gcd(int a, int b) {
		//O(log(min(a,b)))
		if (b == 0)
			return a;

		return gcd(b, a % b);
	}

	private static long modExp(long a, long b) {
		if (b == 0)
			return 1;

		a %= MOD;

		long exp = modExp(a, b / 2);

		if (b % 2 == 0) {
			return (exp * exp) % MOD;
		} else {
			return (a * ((exp * exp) % MOD)) % MOD;
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Stack;

public class D {
	//author: Nagabhushan S Baddi

	private static int n, m;
	private static char[][] a;
	private static int d;
	private static String s;
	private static HashMap<Integer, ArrayList<Integer>> g;

	public static void main(String[] args) {
		int t = ini();
		while (t-- > 0) {
			n = ini();
			m = ini();
			a = new char[n][m];
			for(int i=0; i<n; i++) {
				a[i] = ins().toCharArray();
			}

			Stack<int[]> stack = new Stack<>();

			boolean[][] mark = new boolean[n][m];

			boolean[][] block = new boolean[n][m];

			int[] dx = {1, -1, 0, 0};
			int[] dy = {0, 0, -1, 1};

			stack.push(new int[] {n-1, m-1});
			mark[n-1][m-1] = true;

			while(!stack.isEmpty()) {
				int[] node = stack.pop();
				int x = node[0];
				int y = node[1];
				for(int k=0; k<4; k++) {
					int nx = x+dx[k];
					int ny = y+dy[k];
					if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
					stack.push(new int[] {nx, ny});
					mark[nx][ny] = true;
				}
			}

			boolean escape = false;

			boolean whiteEscape = true;

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]=='G' && !mark[i][j]) {
						whiteEscape = false;
					}
					if (a[i][j]=='B' && mark[i][j]) {
						escape = true;
					}
				}
			}

			if (!whiteEscape) {
				println("No");
				continue;
			}

//			println("HEY");

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]!='.') continue;
					for(int x=0; x<n; x++) Arrays.fill(mark[x], false);

//
//					if (i==n-1 && j==m-1) continue;

					if (!(i==n-1 && j==m-1)) {
						stack.push(new int[] {n-1, m-1});
						mark[n-1][m-1] = true;
					}

					while(!stack.isEmpty()) {
						int[] node = stack.pop();
						int x = node[0];
						int y = node[1];
						for(int k=0; k<4; k++) {
							int nx = x+dx[k];
							int ny = y+dy[k];
							if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
							stack.push(new int[] {nx, ny});
							mark[nx][ny] = true;
						}
					}

					boolean canBe = true;

					boolean blackWidow = false;

					out:
					for(int x=0; x<n; x++) {
						for(int y=0; y<m; y++) {
							if (a[x][y]=='G' && !mark[x][y]) {
								canBe = false;
								break out;
							}
							if (a[x][y]=='B' && mark[x][y]) {
								blackWidow = true;
							}
						}
					}

//					System.out.println(i+" "+j+" "+canBe);

					if (!canBe) continue;

					whiteEscape = true;

					block[i][j] = true;
					escape = blackWidow;
				}

			}

			println(!escape && whiteEscape?"Yes":"No");
		}

		out.flush();
		out.close();

	}

	//CONSTANTS
	private static final int MOD = (int) 1e9 + 7;

	//NONPROBLEM CODE

	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	//SORT SHORTCUTS

	private static void sort(int[] a) {
		int n = a.length;
		Integer[] b = new Integer[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	private static void sort(long[] a) {
		int n = a.length;
		Long[] b = new Long[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	//INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	private static long inl() {
		return in.nextLong();
	}

	private static String ins() {
		return in.readString();
	}

	//PRINT SHORTCUTS

	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.write("\n");
	}

	private static void pd(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.flush();
		out.write("\n");
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
	}

	//GRAPH SHORTCUTS

	private static HashMap<Integer, ArrayList<Integer>> intree(int n) {

		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();
		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;
	}

	private static HashMap<Integer, ArrayList<Integer>> ingraph(int n, int m) {
		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;

	}

	private static HashMap<Integer, ArrayList<Edge>> inweightedgraph(int n, int m) {
		HashMap<Integer, ArrayList<Edge>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			int w = ini();
			Edge edge = new Edge(u, v, w);
			g.get(u).add(edge);
			g.get(v).add(edge);
		}

		return g;

	}

	private static class Edge implements Comparable<Edge> {
		private int u, v;
		private long w;

		public Edge(int a, int b, long c) {
			u = a;
			v = b;
			w = c;
		}

		public int other(int x) {
			return (x == u ? v : u);
		}

		public int compareTo(Edge edge) {
			return Long.compare(w, edge.w);
		}
	}

	private static class Pair {
		private int u, v;

		public Pair(int a, int b) {
			u = a;
			v = b;
		}

		public int hashCode() {
			return u + v + u * v;
		}

		public boolean equals(Object object) {
			Pair pair = (Pair) object;
			return u == pair.u && v == pair.v;
		}
	}

	private static class Node implements Comparable<Node> {
		private int u;
		private long dist;

		public Node(int a, long b) {
			u = a;
			dist = b;
		}

		public int compareTo(Node node) {
			return Long.compare(dist, node.dist);
		}
	}

	//MATHS AND NUMBER THEORY SHORTCUTS

	private static int gcd(int a, int b) {
		//O(log(min(a,b)))
		if (b == 0)
			return a;

		return gcd(b, a % b);
	}

	private static long modExp(long a, long b) {
		if (b == 0)
			return 1;

		a %= MOD;

		long exp = modExp(a, b / 2);

		if (b % 2 == 0) {
			return (exp * exp) % MOD;
		} else {
			return (a * ((exp * exp) % MOD)) % MOD;
		}
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Stack;

public class D2 {
	//author: Nagabhushan S Baddi

	private static int n, m;
	private static char[][] a;
	private static int d;
	private static String s;
	private static HashMap<Integer, ArrayList<Integer>> g;

	public static void main(String[] args) {
		int t = ini();

		nextCase:
		while (t-- > 0) {
			n = ini();
			m = ini();
			a = new char[n][m];
			for(int i=0; i<n; i++) {
				a[i] = ins().toCharArray();
			}

			Stack<int[]> stack = new Stack<>();

			boolean[][] mark = new boolean[n][m];

			boolean[][] block = new boolean[n][m];

			int[] dx = {1, -1, 0, 0};
			int[] dy = {0, 0, -1, 1};

			stack.push(new int[] {n-1, m-1});
			mark[n-1][m-1] = true;

			while(!stack.isEmpty()) {
				int[] node = stack.pop();
				int x = node[0];
				int y = node[1];
				for(int k=0; k<4; k++) {
					int nx = x+dx[k];
					int ny = y+dy[k];
					if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
					stack.push(new int[] {nx, ny});
					mark[nx][ny] = true;
				}
			}

			boolean escape = false;

			boolean whiteEscape = true;

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]=='G' && !mark[i][j]) {
						whiteEscape = false;
					}
					if (a[i][j]=='B' && mark[i][j]) {
						escape = true;
					}
				}
			}

			if (!whiteEscape) {
				println("No");
				continue;
			}
			if (!escape) {
				println("Yes");
				continue;
			}

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]!='B') continue;
					for(int k=0; k<4; k++) {
						int nx = i+dx[k];
						int ny = j+dy[k];
						if (nx<0 || nx>=n || ny<0 || ny>=m) continue;
						if (a[nx][ny]=='.') {
							block[nx][ny] = true;
						}
						if (a[nx][ny]=='G') {
							println("No");
							continue nextCase;
						}
					}
				}
			}

//			if (block[n-1][m-1]) {
//				println("No");
//				continue;
//			}

			mark = new boolean[n][m];

			if (!block[n-1][m-1]) {
				stack.push(new int[] {n-1, m-1});
				mark[n-1][m-1] = true;
			}

			while(!stack.isEmpty()) {
				int[] node = stack.pop();
				int x = node[0];
				int y = node[1];
				for(int k=0; k<4; k++) {
					int nx = x+dx[k];
					int ny = y+dy[k];
					if (nx<0 || nx>=n || ny<0 || ny>=m || mark[nx][ny] || block[nx][ny] || a[nx][ny]=='#') continue;
					stack.push(new int[] {nx, ny});
					mark[nx][ny] = true;
				}
			}

			whiteEscape = true;

			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					if (a[i][j]=='G' && !mark[i][j]) {
						whiteEscape = false;
					}
				}
			}

//			println("HEY");

			println(whiteEscape?"Yes":"No");
		}

		out.flush();
		out.close();

	}

	//CONSTANTS
	private static final int MOD = (int) 1e9 + 7;

	//NONPROBLEM CODE

	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	private static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	//SORT SHORTCUTS

	private static void sort(int[] a) {
		int n = a.length;
		Integer[] b = new Integer[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	private static void sort(long[] a) {
		int n = a.length;
		Long[] b = new Long[n];
		for (int i = 0; i < n; i++) {
			b[i] = a[i];
		}

		Arrays.sort(b);

		for (int i = 0; i < n; i++) {
			a[i] = b[i];
		}
	}

	//INPUT SHORTCUTS

	private static int[] ina(int n) {
		int[] temp = new int[n];
		for (int i = 0; i < n; i++) {
			temp[i] = in.nextInt();
		}
		return temp;
	}

	private static int ini() {
		return in.nextInt();
	}

	private static long inl() {
		return in.nextLong();
	}

	private static String ins() {
		return in.readString();
	}

	//PRINT SHORTCUTS

	private static void println(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.write("\n");
	}

	private static void pd(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
		out.flush();
		out.write("\n");
	}

	private static void print(Object... o) {
		for (Object x : o) {
			out.write(x + "");
		}
	}

	//GRAPH SHORTCUTS

	private static HashMap<Integer, ArrayList<Integer>> intree(int n) {

		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();
		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < n - 1; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;
	}

	private static HashMap<Integer, ArrayList<Integer>> ingraph(int n, int m) {
		HashMap<Integer, ArrayList<Integer>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}

		return g;

	}

	private static HashMap<Integer, ArrayList<Edge>> inweightedgraph(int n, int m) {
		HashMap<Integer, ArrayList<Edge>> g = new HashMap<>();

		for (int i = 0; i < n; i++) {
			g.put(i, new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			int u = ini() - 1;
			int v = ini() - 1;
			int w = ini();
			Edge edge = new Edge(u, v, w);
			g.get(u).add(edge);
			g.get(v).add(edge);
		}

		return g;

	}

	private static class Edge implements Comparable<Edge> {
		private int u, v;
		private long w;

		public Edge(int a, int b, long c) {
			u = a;
			v = b;
			w = c;
		}

		public int other(int x) {
			return (x == u ? v : u);
		}

		public int compareTo(Edge edge) {
			return Long.compare(w, edge.w);
		}
	}

	private static class Pair {
		private int u, v;

		public Pair(int a, int b) {
			u = a;
			v = b;
		}

		public int hashCode() {
			return u + v + u * v;
		}

		public boolean equals(Object object) {
			Pair pair = (Pair) object;
			return u == pair.u && v == pair.v;
		}
	}

	private static class Node implements Comparable<Node> {
		private int u;
		private long dist;

		public Node(int a, long b) {
			u = a;
			dist = b;
		}

		public int compareTo(Node node) {
			return Long.compare(dist, node.dist);
		}
	}

	//MATHS AND NUMBER THEORY SHORTCUTS

	private static int gcd(int a, int b) {
		//O(log(min(a,b)))
		if (b == 0)
			return a;

		return gcd(b, a % b);
	}

	private static long modExp(long a, long b) {
		if (b == 0)
			return 1;

		a %= MOD;

		long exp = modExp(a, b / 2);

		if (b % 2 == 0) {
			return (exp * exp) % MOD;
		} else {
			return (a * ((exp * exp) % MOD)) % MOD;
		}
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Round648 {

	static int X[] = { -1, 0, 0, 1 };
	static int Y[] = { 0, -1, 1, 0 };

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	static class Node {
		int val;
		int type;
		int ind;

		public Node(int val, int type, int ind) {
			this.val = val;
			this.type = type;
			this.ind = ind;
		}
	}

	public static long[] initArray(int n, Reader scan) throws IOException {

		long arr[] = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scan.nextLong();
		}

		return arr;
	}

	public static long sum(long arr[]) {

		long sum = 0;
		for (long i : arr) {
			sum += (long) i;
		}

		return sum;
	}

	public static long max(long arr[]) {

		long max = Long.MIN_VALUE;

		for (long i : arr) {
			max = Math.max(i, max);
		}

		return max;
	}

	public static long min(long arr[]) {
		long min = Long.MAX_VALUE;

		for (long i : arr) {
			min = Math.min(i, min);
		}

		return min;
	}

	public static List<Integer>[] initAdjacency(int n, int e, Reader scan, boolean type) throws IOException {

		List<Integer> adj[] = new ArrayList[n + 1];

		for (int i = 0; i < e; i++) {
			int u = scan.nextInt();
			int v = scan.nextInt();

			if (adj[u] == null)
				adj[u] = new ArrayList<>();
			if (type && adj[v] == null)
				adj[v] = new ArrayList<>();

			adj[u].add(v);

			if (type)
				adj[v].add(u);

		}

		return adj;
	}

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while (t-- > 0) {
			int n = scan.nextInt();
			int m = scan.nextInt();

			int arr[][] = new int[n][m];

			for (int i = 0; i < n; i++) {
				String s = scan.next();
				for (int j = 0; j < m; j++) {
					if (s.charAt(j) == '.') {
						arr[i][j] = 0;
					}
					if (s.charAt(j) == '#') {
						arr[i][j] = 1;
					}

					if (s.charAt(j) == 'G') {
						arr[i][j] = 2;
					}
					if (s.charAt(j) == 'B') {
						arr[i][j] = 3;
					}
				}
			}

			D(arr, n, m);
		}

	}

	public static void A(int n, int m, long arr[][]) {

		int rC = 0;
		int cC = 0;

		int rows[] = new int[n];
		int cols[] = new int[m];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 1) {
					rows[i]++;
					cols[j]++;
				}
			}
		}

		for (int i : rows) {
			if (i == 0) {
				rC++;
			}
		}

		for (int j : cols) {
			if (j == 0) {
				cC++;
			}
		}

		int turn = 0;

		turn = Math.min(rC, cC) % 2;

		if (turn == 0) {
			System.out.println("Vivek");
		} else {
			System.out.println("Ashish");
		}

	}

	public static void B(List<Node> arr) {

		boolean allSame = true;
		boolean isInc = true;

		int last = 0;
		int lastType = arr.get(0).type;
		for (int i = 0; i < arr.size(); i++) {
			if (arr.get(i).type != lastType) {
				System.out.println("Yes");
				return;
			}

			if (arr.get(i).val < last) {
				isInc = false;
			}

			last = arr.get(i).val;
		}

		if (isInc) {
			System.out.println("Yes");
		}

		else {
			System.out.println("No");
		}

	}

	public static int C(long arr1[], long arr2[], int n) {

		int ind[] = new int[n + 1];

		for (int i = 0; i < n; i++) {
			ind[(int) arr2[i]] = i;
		}

		int dist[] = new int[n];

		for (int i = 0; i < n; i++) {

			long val = arr1[i];
			int idx = ind[(int) val];
			if (idx < i) {
				dist[i] = i - idx;
			} else {
				dist[i] = n - idx + i;
			}
		}

		int maxVals[] = new int[n + 1];
		for (int i : dist) {
			maxVals[i]++;
		}

		int ans = 1;

		for (int i : maxVals) {
			ans = Math.max(i, ans);
		}

		return ans;

	}

	public static void D(int arr[][], int n, int m) {

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 3) {

					for (int k = 0; k < 4; k++) {
						int x = i + X[k];
						int y = j + Y[k];

						if (x >= 0 && x < n && y >= 0 && y < m) {
							if (arr[x][y] == 2) {
								System.out.println("No");
								return;
							} else if (arr[x][y] == 0) {
								arr[x][y] = 1;

							}
						}
					}
				}
			}
		}

		int r[][] = new int[n][m];

		dfs(n - 1, m - 1, r, arr, n, m);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (arr[i][j] == 3 && r[i][j] == 1) {

					System.out.println("No");
					return;

				}

				if (arr[i][j] == 2 && r[i][j] == 0) {

					System.out.println("No");
					return;

				}
			}
		}

		System.out.println("Yes");

	}

	public static void dfs(int i, int j, int reachable[][], int arr[][], int n, int m) {

		if(arr[i][j]==1) {
			reachable[i][j]=0;
			return;
		}

		reachable[i][j] = 1;

		for (int k = 0; k < 4; k++) {
			int x = i + X[k];
			int y = j + Y[k];

			if (x >= 0 && x < n && y >= 0 && y < m && arr[x][y] != 1 && reachable[x][y] == 0) {
				dfs(x, y, reachable, arr, n, m);
			}
		}

	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Round648 {

	static int X[]= {-1,0,0,1};
	static int Y[]= {0,-1,1,0};
	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	static class Node{
		int val;
		int type;
		int ind;

		public Node(int val, int type, int ind) {
			this.val=val;
			this.type=type;
			this.ind=ind;
		}
	}

	public static long[] initArray(int n, Reader scan) throws IOException {

		long arr[] = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scan.nextLong();
		}

		return arr;
	}

	public static long sum(long arr[]) {

		long sum = 0;
		for (long i : arr) {
			sum += (long) i;
		}

		return sum;
	}

	public static long max(long arr[]) {

		long max = Long.MIN_VALUE;

		for (long i : arr) {
			max = Math.max(i, max);
		}

		return max;
	}

	public static long min(long arr[]) {
		long min = Long.MAX_VALUE;

		for (long i : arr) {
			min = Math.min(i, min);
		}

		return min;
	}

	public static List<Integer>[] initAdjacency(int n, int e, Reader scan, boolean type) throws IOException{

		List<Integer> adj[]=new ArrayList[n+1];

		for(int i=0;i<e;i++) {
			int u=scan.nextInt();
			int v=scan.nextInt();

			if(adj[u]==null) adj[u]=new ArrayList<>();
			if(type&&adj[v]==null) adj[v]=new ArrayList<>();

			adj[u].add(v);

			if(type) adj[v].add(u);

		}

		return adj;
	}

	public static void main(String[] args) throws IOException {

		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		while(t-->0) {
			int n=scan.nextInt();
			int m=scan.nextInt();

			int arr[][]=new int[n][m];

			for(int i=0;i<n;i++) {
				String s=scan.next();
				for(int j=0;j<m;j++) {
					if(s.charAt(j)=='.') {
						arr[i][j]=0;
					}
					if(s.charAt(j)=='#') {
						arr[i][j]=1;
					}

					if(s.charAt(j)=='G') {
						arr[i][j]=2;
					}
					if(s.charAt(j)=='B') {
						arr[i][j]=3;
					}
				}
			}

			D(arr, n, m);
		}

	}

	public static void A(int n, int m ,long arr[][]) {

		int rC=0;
		int cC=0;

		int rows[]=new int[n];
		int cols[]=new int[m];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==1) {
					rows[i]++;
					cols[j]++;
				}
			}
		}

		for(int i: rows) {
			if(i==0) {
				rC++;
			}
		}

		for(int j: cols) {
			if(j==0) {
				cC++;
			}
		}

		int turn=0;

		turn= Math.min(rC, cC)%2;

		if(turn==0) {
			System.out.println("Vivek");
		}else {
			System.out.println("Ashish");
		}

	}

	public static void B(List<Node> arr) {

		boolean allSame=true;
		boolean isInc=true;

		int last=0;
		int lastType= arr.get(0).type;
		for(int i=0;i<arr.size();i++) {
			if(arr.get(i).type!=lastType) {
				System.out.println("Yes");
				return;
			}

			if(arr.get(i).val<last) {
				isInc=false;
			}

			last= arr.get(i).val;
		}

		if(isInc) {
			System.out.println("Yes");
		}

		else {
			System.out.println("No");
		}

	}

	public static int C(long arr1[], long arr2[], int n) {

		int ind[]=new int[n+1];

		for(int i=0;i<n;i++) {
			ind[(int)arr2[i]]=i;
		}

		int dist[]=new int[n];

		for(int i=0;i<n;i++) {

			long val=arr1[i];
			int idx= ind[(int)val];
			if(idx<i) {
				dist[i]= i-idx;
			}else {
				dist[i]= n-idx+i;
			}
		}

		int maxVals[]=new int[n+1];
		for(int i: dist) {
			maxVals[i]++;
		}

		int ans=1;

		for(int i: maxVals) {
			ans=Math.max(i, ans);
		}

		return ans;

	}

	public static void D(int arr[][], int n, int m) {

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==3) {

					for(int k=0;k<4;k++) {
						int x=i+X[k];
						int y=j+Y[k];

						if(x>=0&&x<n&&y>=0&&y<m) {
							if(arr[x][y]==2) {
								System.out.println("No");
								return;
							}else if(arr[x][y]==0) {
								arr[x][y]=1;

							}
						}
					}
				}
			}
		}

		boolean visited[][]=new boolean[n][m];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==2) {
					boolean ans= dfs(i, j, visited, arr, n, m);
					if(!ans) {
						System.out.println("No");
						return;
					}
				}
			}
		}

		System.out.println("Yes");

	}

	public static boolean dfs(int i, int j, boolean visited[][], int arr[][], int n, int m) {

		if(i==n-1&&j==m-1) {

			if(arr[i][j]==1) {
				return false;
			}
			return true;
		}

		visited[i][j]=true;

		boolean ans=false;

		for(int k=0;k<4;k++) {
			int x=i+X[k];
			int y=j+Y[k];

			if(x>=0&&x<n&&y>=0&&y<m&&arr[x][y]!=1&&!visited[x][y]) {
				ans= ans|| dfs(x, y, visited, arr, n, m);
			}
		}

		return ans;
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Round648 {

	static int X[]= {-1,0,0,1};
	static int Y[]= {0,-1,1,0};
	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	static class Node{
		int val;
		int type;
		int ind;

		public Node(int val, int type, int ind) {
			this.val=val;
			this.type=type;
			this.ind=ind;
		}
	}

	public static long[] initArray(int n, Reader scan) throws IOException {

		long arr[] = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scan.nextLong();
		}

		return arr;
	}

	public static long sum(long arr[]) {

		long sum = 0;
		for (long i : arr) {
			sum += (long) i;
		}

		return sum;
	}

	public static long max(long arr[]) {

		long max = Long.MIN_VALUE;

		for (long i : arr) {
			max = Math.max(i, max);
		}

		return max;
	}

	public static long min(long arr[]) {
		long min = Long.MAX_VALUE;

		for (long i : arr) {
			min = Math.min(i, min);
		}

		return min;
	}

	public static List<Integer>[] initAdjacency(int n, int e, Reader scan, boolean type) throws IOException{

		List<Integer> adj[]=new ArrayList[n+1];

		for(int i=0;i<e;i++) {
			int u=scan.nextInt();
			int v=scan.nextInt();

			if(adj[u]==null) adj[u]=new ArrayList<>();
			if(type&&adj[v]==null) adj[v]=new ArrayList<>();

			adj[u].add(v);

			if(type) adj[v].add(u);

		}

		return adj;
	}

	public static void main(String[] args) throws IOException {

		Scanner scan=new Scanner(System.in);
		int t=scan.nextInt();
		while(t-->0) {
			int n=scan.nextInt();
			int m=scan.nextInt();

			int arr[][]=new int[n][m];

			for(int i=0;i<n;i++) {
				String s=scan.next();
				for(int j=0;j<m;j++) {
					if(s.charAt(j)=='.') {
						arr[i][j]=0;
					}
					if(s.charAt(j)=='#') {
						arr[i][j]=1;
					}

					if(s.charAt(j)=='G') {
						arr[i][j]=2;
					}
					if(s.charAt(j)=='B') {
						arr[i][j]=3;
					}
				}
			}

			D(arr, n, m);
		}

	}

	public static void A(int n, int m ,long arr[][]) {

		int rC=0;
		int cC=0;

		int rows[]=new int[n];
		int cols[]=new int[m];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==1) {
					rows[i]++;
					cols[j]++;
				}
			}
		}

		for(int i: rows) {
			if(i==0) {
				rC++;
			}
		}

		for(int j: cols) {
			if(j==0) {
				cC++;
			}
		}

		int turn=0;

		turn= Math.min(rC, cC)%2;

		if(turn==0) {
			System.out.println("Vivek");
		}else {
			System.out.println("Ashish");
		}

	}

	public static void B(List<Node> arr) {

		boolean allSame=true;
		boolean isInc=true;

		int last=0;
		int lastType= arr.get(0).type;
		for(int i=0;i<arr.size();i++) {
			if(arr.get(i).type!=lastType) {
				System.out.println("Yes");
				return;
			}

			if(arr.get(i).val<last) {
				isInc=false;
			}

			last= arr.get(i).val;
		}

		if(isInc) {
			System.out.println("Yes");
		}

		else {
			System.out.println("No");
		}

	}

	public static int C(long arr1[], long arr2[], int n) {

		int ind[]=new int[n+1];

		for(int i=0;i<n;i++) {
			ind[(int)arr2[i]]=i;
		}

		int dist[]=new int[n];

		for(int i=0;i<n;i++) {

			long val=arr1[i];
			int idx= ind[(int)val];
			if(idx<i) {
				dist[i]= i-idx;
			}else {
				dist[i]= n-idx+i;
			}
		}

		int maxVals[]=new int[n+1];
		for(int i: dist) {
			maxVals[i]++;
		}

		int ans=1;

		for(int i: maxVals) {
			ans=Math.max(i, ans);
		}

		return ans;

	}

	public static void D(int arr[][], int n, int m) {

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==3) {

					for(int k=0;k<4;k++) {
						int x=i+X[k];
						int y=j+Y[k];

						if(x>=0&&x<n&&y>=0&&y<m) {
							if(arr[x][y]==2) {
								System.out.println("No");
								return;
							}else if(arr[x][y]==0) {
								arr[x][y]=1;

							}
						}
					}
				}
			}
		}

		boolean visited[][]=new boolean[n][m];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==2) {
					boolean ans= dfs(i, j, visited, arr, n, m);
					if(!ans) {
						System.out.println("No");
						return;
					}
				}
			}
		}

		visited=new boolean[n][m];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				if(arr[i][j]==3) {
					boolean ans= dfs(i, j, visited, arr, n, m);
					if(ans) {
						System.out.println("No");
						return;
					}
				}
			}
		}

		System.out.println("Yes");

	}

	public static boolean dfs(int i, int j, boolean visited[][], int arr[][], int n, int m) {

		if(i==n-1&&j==m-1) {

			if(arr[i][j]==1) {
				return false;
			}
			return true;
		}

		visited[i][j]=true;

		boolean ans=false;

		for(int k=0;k<4;k++) {
			int x=i+X[k];
			int y=j+Y[k];

			if(x>=0&&x<n&&y>=0&&y<m&&arr[x][y]!=1&&!visited[x][y]) {
				ans= ans|| dfs(x, y, visited, arr, n, m);
			}
		}

		return ans;
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.Vector;

import static java.util.Collections.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class cf {

    private static final int MOD = (int) (1e9 + 7), MOD_FFT = 998244353;
    private static Scanner in;
    private static final Reader r = new Reader();
    private static final PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    private static final boolean thread = false, FASTIO = true;

    public static void main(final String[] args) throws Exception {
        if (!thread) {
            final int testcases = HAS_TEST_CASES ? ni() : 1;
            for (int i = 1; i <= testcases; i++) {
                // out.print("Case #" + (i + 1) + ": ");
                try {
                    solve();
                } catch (final Exception e) {
                    pn(e.getMessage());
                    pni("idk Exception");
                    e.printStackTrace(System.err);
                    System.exit(0);
                }
            }
            out.flush();
        }
    }

    static final boolean HAS_TEST_CASES = true;
    static final int SCAN_LINE_LENGTH = 1000002;

    static int n, a[], b[], e[][];

    private static Vector<Integer> adj[], v = new Vector<>();

    static void solve() throws Exception {
        int n = ni(), m = ni();
        char s[][] = new char[n][m];
        int v[][] = new int[n][m];
        for (int i = 0; i < s.length; i++) {
            s[i] = n().trim().toCharArray();
        }
        for (int i = 0; i < s.length; i++) {
            for (int j = 0; j < s[0].length; j++) {
                if (v[i][j] == 1)
                    continue;
                if (s[i][j] == 'B')
                    dfs(s, v, i, j);
            }
        }
        v = new int[n][m];
        reversedfs(s, v, n - 1, m - 1);
        for (int i = 0; i < v.length; i++) {
            for (int j = 0; j < v[0].length; j++) {
                if (v[i][j] == 1 && s[i][j] == 'B') {
                    pn("No");
                    return;
                }
                if (v[i][j] == 0 && s[i][j] == 'G') {
                    pn("No");
                    return;
                }
            }
        }
        pn("Yes");
    }

    private static void reversedfs(char[][] s, int[][] v, int i, int j) {
        if (i < 0 || j < 0 || i >= s.length || j >= s[0].length || s[i][j] == '#')
            return;
        if (v[i][j] == 1)
            return;
        v[i][j] = 1;
        reversedfs(s, v, i + 1, j);
        reversedfs(s, v, i, j + 1);
        reversedfs(s, v, i - 1, j);
        reversedfs(s, v, i, j - 1);
    }

    private static void dfs(char[][] s, int[][] v, int i, int j) {
        if (i < 0 || j < 0 || i >= s.length || j >= s[0].length || s[i][j] == 'G' || s[i][j] == '#')
            return;
        if (s[i][j] == 'B' && v[i][j] == 1)
            return;
        v[i][j] = 1;
        if (s[i][j] == '.') {
            s[i][j] = '#';
            return;
        }
        dfs(s, v, i + 1, j);
        dfs(s, v, i, j + 1);
        dfs(s, v, i - 1, j);
        dfs(s, v, i, j - 1);
    }

    private static void swap(final int i, final int j) {
        final int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }

    private static void swapb(final int i, final int j) {
        final int temp = b[i];
        b[i] = b[j];
        b[j] = temp;
    }

    private static boolean isMulOverflow(final long A, final long B) {
        if (A == 0 || B == 0)
            return false;
        final long result = A * B;
        if (A == result / B)
            return true;
        return false;
    }

    private static int gcd(final int a, final int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    private static class Pair<T, E> implements Comparable<Pair<T, E>> {
        T fir;
        E snd;

        Pair() {
        }

        Pair(final T x, final E y) {
            this.fir = x;
            this.snd = y;
        }

        @Override
        @SuppressWarnings("unchecked")
        public int compareTo(final Pair<T, E> o) {
            final int c = ((Comparable<T>) fir).compareTo(o.fir);
            return c != 0 ? c : ((Comparable<E>) snd).compareTo(o.snd);
        }

    }

    private static class pi implements Comparable<pi> {
        int fir, snd;

        pi() {
        }

        pi(final int a, final int b) {
            fir = a;
            snd = b;
        }

        public int compareTo(final pi o) {
            return fir == o.fir ? snd - o.snd : fir - o.fir;
        }

    }

    private static <T> void checkV(final Vector<T> adj[], final int i) {
        adj[i] = adj[i] == null ? new Vector<>() : adj[i];
    }

    private static int[] na(final int n) throws Exception {
        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = ni();
        }
        return a;
    }

    private static int[] na1(final int n) throws Exception {
        final int[] a = new int[n + 1];
        for (int i = 1; i < a.length; i++) {
            a[i] = ni();
        }
        return a;
    }

    private static String n() throws IOException {
        return FASTIO ? r.readToken() : in.next();
    }

    private static String nln() throws IOException {
        return FASTIO ? r.readLine() : in.nextLine();
    }

    private static int ni() throws IOException {
        return FASTIO ? r.nextInt() : in.nextInt();
    }

    private static long nl() throws IOException {
        return FASTIO ? r.nextLong() : in.nextLong();
    }

    private static double nd() throws IOException {
        return FASTIO ? r.nextDouble() : in.nextDouble();
    }

    private static void p(final Object o) {
        out.print(o);
    }

    private static void pn(final Object o) {
        out.println(o);
    }

    private static void pn() {
        out.println("");
    }

    private static void pni(final Object o) {
        out.println(o);
        out.flush();
    }

    private static class Reader {
        private final int BUFFER_SIZE = 1 << 19;
        private final DataInputStream din;
        private final byte[] buffer;
        private int bufferPointer, bytesRead;
        private StringTokenizer st;
        private final BufferedReader br;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public Reader(final String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            br = new BufferedReader(new FileReader(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String next() throws Exception {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (final IOException e) {
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        public String nextLine() throws Exception {
            String str = "";
            try {
                str = br.readLine();
            } catch (final IOException e) {
                throw new Exception(e.toString());
            }
            return str;
        }

        final byte[] buf = new byte[SCAN_LINE_LENGTH];

        public String readLine() throws IOException {
            int cnt = 0;
            int c;
            while ((c = read()) != -1) {
                if (c == '\n')
                    if (cnt == 0)
                        continue;
                    else
                        break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public String readToken() throws IOException {
            int cnt = 0;
            int c;
            while ((c = read()) != -1) {
                if (c == '\n' || c == ' ')
                    if (cnt == 0)
                        continue;
                    else
                        break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            final boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            final boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            final boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    static {
        if (!FASTIO)
            in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        if (thread)
            new Thread(null, new Runnable() {
                @Override
                public void run() {
                    try {
                        final int testcases = HAS_TEST_CASES ? ni() : 1;
                        for (int i = 1; i <= testcases; i++) {
                            // out.print("Case #" + (i + 1) + ": ");
                            try {
                                solve();
                            } catch (final ArrayIndexOutOfBoundsException e) {
                                e.printStackTrace(System.err);
                                System.exit(-1);
                            } catch (final Exception e) {
                                pni("idk Exception in solve");
                                e.printStackTrace(System.err);
                                System.exit(-1);
                            }
                        }
                        out.flush();
                    } catch (final Throwable t) {
                        t.printStackTrace(System.err);
                        System.exit(-1);
                    }
                }
            }, "rec", (1L << 28)).start();
    }

    @SuppressWarnings({ "unchecked" })
    private static <T> T deepCopy(final T old) {
        try {
            return (T) deepCopyObject(old);
        } catch (final IOException | ClassNotFoundException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return null;
    }

    private static Object deepCopyObject(final Object oldObj) throws IOException, ClassNotFoundException {
        ObjectOutputStream oos = null;
        ObjectInputStream ois = null;
        try {
            final ByteArrayOutputStream bos = new ByteArrayOutputStream(); // A
            oos = new ObjectOutputStream(bos); // B
            // serialize and pass the object
            oos.writeObject(oldObj); // C
            oos.flush(); // D
            final ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray()); // E
            ois = new ObjectInputStream(bin); // F
            // return the new object
            return ois.readObject(); // G
        } catch (final ClassNotFoundException e) {
            pni("Exception in ObjectCloner = " + e);
            throw (e);
        } finally {
            oos.close();
            ois.close();
        }
    }

}


import java.util.*;
import java.io.*;
import java.awt.*;
public class Solution{
    public static void main(String[] args)throws IOException{
        FastReader in=new FastReader();
        PrintWriter wr=new PrintWriter(System.out);
        int tc=in.nextInt();
        StringBuilder ans=new StringBuilder();
        while(tc-->0){
            int n=in.nextInt(),m=in.nextInt();
            int[][] mat=new int[n][m];
            int cntt=0;
            for(int i=0;i<n;i++){
                String s=in.next();
                //System.out.println(s);
                for(int j=0;j<m;j++){
                    char ch=s.charAt(j);
                    if(ch=='.')mat[i][j]=0;
                    else if(ch=='G'){mat[i][j]=2;cntt+=1;}
                    else if(ch=='B')mat[i][j]=1;
                    else mat[i][j]=-1;
                }
            }
            if(cntt==0 && !(mat[n-1][m-1]==1)){
                ans.append("Yes\n");
                //wr.flush();
                continue;
            }
            int[] a={1,-1,0,0};
            int[] b={0,0,1,-1};
            /*for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    wr.write(mat[i][j]+" ");
                }
                wr.write("\n");
                wr.flush();
            }*/
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && mat[x][y]==0)mat[x][y]=-1;
                        }
                    }
                }
            }
            if(mat[n-1][m-1]==-1 || mat[n-1][m-1]==1){
                ans.append("No\n");
                //wr.flush();
                continue;
            }
            boolean ch=true;
            boolean[][] yes=new boolean[n][m];
            for(int i=0;i<n;i++)for(int j=0;j<m;j++)yes[i][j]=false;
            yes=bfs(mat,n-1,m-1);

            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==2){
                        if(yes[i][j]==false){ch=false;break;}
                        /*boolean get=check(mat,i,j,n,m);
                        if(get==false){
                            ch=false;
                            break;
                        }
                        yes[i][j]=true;*/
                    }
                }
                if(ch==false)break;
            }
            if(ch==false){
                ans.append("No\n");
                //wr.flush();
                continue;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && yes[x][y]==true){
                                ch=false;
                                break;
                            }
                        }
                    }
                }
            }
            if(ch==false)ans.append("No\n");
            else ans.append("Yes\n");
            //wr.flush();
        }
        wr.write(ans+"");
        wr.flush();
    }
    static boolean[][] bfs(int[][] mat,int n,int m){
        Point pt=new Point(n,m);
        Queue<Point> q=new LinkedList<Point>();
        q.add(pt);
        int[] a={1,-1,0,0};
        int[] b={0,0,1,-1};
        boolean[][] vis=new boolean[n+1][m+1];
        boolean[][] ret=new boolean[n+1][m+1];
        for(int ii=0;ii<=n;ii++){
            for(int jj=0;jj<=m;jj++){
                vis[ii][jj]=false;
                ret[ii][jj]=false;
            }
        }
        while(!q.isEmpty()){
            Point rem=q.remove();
            int x=(int)rem.getX(),y=(int)rem.getY();
            vis[x][y]=true;
            for(int ii=0;ii<4;ii++){
                int x1=x+a[ii],y1=y+b[ii];
                if(x1>=0 && x1<=n && y1>=0 && y1<=m && mat[x1][y1]!=-1 && vis[x1][y1]==false){
                    q.add(new Point(x1,y1));
                    ret[x1][y1]=true;
                    vis[x1][y1]=true;
                    //if(x1==n-1 && y1==m-1)return true;
                }
            }
        }
        return ret;
    }
    static boolean check(int[][] mat,int i,int j,int n,int m){
        Point pt=new Point(i,j);
        Queue<Point> q=new LinkedList<Point>();
        q.add(pt);
        int[] a={1,-1,0,0};
        int[] b={0,0,1,-1};
        boolean[][] vis=new boolean[n][m];
        for(int ii=0;ii<n;ii++)for(int jj=0;jj<m;jj++)vis[ii][jj]=false;
        while(!q.isEmpty()){
            Point rem=q.remove();
            int x=(int)rem.getX(),y=(int)rem.getY();
            vis[x][y]=true;
            for(int ii=0;ii<4;ii++){
                int x1=x+a[ii],y1=y+b[ii];
                if(x1>=0 && x1<n && y1>=0 && y1<m && mat[x1][y1]!=-1 && vis[x1][y1]==false){
                    q.add(new Point(x1,y1));
                    vis[x1][y1]=true;
                    if(x1==n-1 && y1==m-1)return true;
                }
            }
            //System.out.println("anant");
        }
        return false;
    }
}
class FastReader{
    public static StringTokenizer st;
    public static BufferedReader in;
    public static PrintWriter pw;
    FastReader(){
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        st = new StringTokenizer("");
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    public static String next() throws IOException {
        while(!st.hasMoreElements() || st == null){
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}


import java.util.*;
import java.io.*;
import java.awt.*;
public class Solution{
    public static void main(String[] args)throws IOException{
        FastReader in=new FastReader();
        PrintWriter wr=new PrintWriter(System.out);
        int tc=in.nextInt();
        StringBuilder ans=new StringBuilder();
        while(tc-->0){
            int n=in.nextInt(),m=in.nextInt();
            int[][] mat=new int[n][m];
            int cntt=0;
            for(int i=0;i<n;i++){
                String s=in.next();
                //System.out.println(s);
                for(int j=0;j<m;j++){
                    char ch=s.charAt(j);
                    if(ch=='.')mat[i][j]=0;
                    else if(ch=='G'){mat[i][j]=2;cntt+=1;}
                    else if(ch=='B')mat[i][j]=1;
                    else mat[i][j]=-1;
                }
            }
            if(cntt==0 && !(mat[n-1][m-1]==1)){
                wr.write("Yes\n");
                wr.flush();
                continue;
            }
            int[] a={1,-1,0,0};
            int[] b={0,0,1,-1};
            /*for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    wr.write(mat[i][j]+" ");
                }
                wr.write("\n");
                wr.flush();
            }*/
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && mat[x][y]==0)mat[x][y]=-1;
                        }
                    }
                }
            }
            if(mat[n-1][m-1]==-1 || mat[n-1][m-1]==1){
                wr.write("No\n");
                wr.flush();
                continue;
            }
            boolean ch=true;
            boolean[][] yes=new boolean[n][m];
            for(int i=0;i<n;i++)for(int j=0;j<m;j++)yes[i][j]=false;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==2){
                        boolean get=check(mat,i,j,n,m);
                        if(get==false){
                            ch=false;
                            break;
                        }
                        yes[i][j]=true;
                    }
                }
                if(ch==false)break;
            }
            if(ch==false){
                wr.write("No\n");
                wr.flush();
                continue;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && yes[x][y]==true){
                                ch=false;
                                break;
                            }
                        }
                    }
                }
            }
            if(ch==false)wr.write("No\n");
            else wr.write("Yes\n");
            wr.flush();
        }
    }
    static boolean check(int[][] mat,int i,int j,int n,int m){
        Point pt=new Point(i,j);
        Queue<Point> q=new LinkedList<Point>();
        q.add(pt);
        int[] a={1,-1,0,0};
        int[] b={0,0,1,-1};
        boolean[][] vis=new boolean[n][m];
        for(int ii=0;ii<n;ii++)for(int jj=0;jj<m;jj++)vis[ii][jj]=false;
        while(!q.isEmpty()){
            Point rem=q.remove();
            int x=(int)rem.getX(),y=(int)rem.getY();
            vis[x][y]=true;
            for(int ii=0;ii<4;ii++){
                int x1=x+a[ii],y1=y+b[ii];
                if(x1>=0 && x1<n && y1>=0 && y1<m && mat[x1][y1]!=-1 && vis[x1][y1]==false){
                    q.add(new Point(x1,y1));
                    vis[x1][y1]=true;
                    if(x1==n-1 && y1==m-1)return true;
                }
            }
            //System.out.println("anant");
        }
        return false;
    }
}
class FastReader{
    public static StringTokenizer st;
    public static BufferedReader in;
    public static PrintWriter pw;
    FastReader(){
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        st = new StringTokenizer("");
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    public static String next() throws IOException {
        while(!st.hasMoreElements() || st == null){
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}


import java.util.*;
import java.io.*;
import java.awt.*;
public class Solution{
    public static void main(String[] args)throws IOException{
        FastReader in=new FastReader();
        PrintWriter wr=new PrintWriter(System.out);
        int tc=in.nextInt();
        StringBuilder ans=new StringBuilder();
        while(tc-->0){
            int n=in.nextInt(),m=in.nextInt();
            int[][] mat=new int[n][m];
            int cntt=0;
            for(int i=0;i<n;i++){
                String s=in.next();
                //System.out.println(s);
                for(int j=0;j<m;j++){
                    char ch=s.charAt(j);
                    if(ch=='.')mat[i][j]=0;
                    else if(ch=='G'){mat[i][j]=2;cntt+=1;}
                    else if(ch=='B')mat[i][j]=1;
                    else mat[i][j]=-1;
                }
            }
            if(cntt==0 && !(mat[n-1][m-1]==1)){
                ans.append("Yes\n");
                //wr.flush();
                continue;
            }
            int[] a={1,-1,0,0};
            int[] b={0,0,1,-1};
            /*for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    wr.write(mat[i][j]+" ");
                }
                wr.write("\n");
                wr.flush();
            }*/
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && mat[x][y]==0)mat[x][y]=-1;
                        }
                    }
                }
            }
            if(mat[n-1][m-1]==-1 || mat[n-1][m-1]==1){
                ans.append("No\n");
                //wr.flush();
                continue;
            }
            boolean ch=true;
            boolean[][] yes=new boolean[n][m];
            for(int i=0;i<n;i++)for(int j=0;j<m;j++)yes[i][j]=false;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==2){
                        boolean get=check(mat,i,j,n,m);
                        if(get==false){
                            ch=false;
                            break;
                        }
                        yes[i][j]=true;
                    }
                }
                if(ch==false)break;
            }
            if(ch==false){
                ans.append("No\n");
                //wr.flush();
                continue;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(mat[i][j]==1){
                        for(int ii=0;ii<4;ii++){
                            int x=i+a[ii],y=j+b[ii];
                            if(x>=0 && x<n && y>=0 && y<m && yes[x][y]==true){
                                ch=false;
                                break;
                            }
                        }
                    }
                }
            }
            if(ch==false)ans.append("No\n");
            else ans.append("Yes\n");
            //wr.flush();
        }
        wr.write(ans+"");
        wr.flush();
    }
    static boolean check(int[][] mat,int i,int j,int n,int m){
        Point pt=new Point(i,j);
        Queue<Point> q=new LinkedList<Point>();
        q.add(pt);
        int[] a={1,-1,0,0};
        int[] b={0,0,1,-1};
        boolean[][] vis=new boolean[n][m];
        for(int ii=0;ii<n;ii++)for(int jj=0;jj<m;jj++)vis[ii][jj]=false;
        while(!q.isEmpty()){
            Point rem=q.remove();
            int x=(int)rem.getX(),y=(int)rem.getY();
            vis[x][y]=true;
            for(int ii=0;ii<4;ii++){
                int x1=x+a[ii],y1=y+b[ii];
                if(x1>=0 && x1<n && y1>=0 && y1<m && mat[x1][y1]!=-1 && vis[x1][y1]==false){
                    q.add(new Point(x1,y1));
                    vis[x1][y1]=true;
                    if(x1==n-1 && y1==m-1)return true;
                }
            }
            //System.out.println("anant");
        }
        return false;
    }
}
class FastReader{
    public static StringTokenizer st;
    public static BufferedReader in;
    public static PrintWriter pw;
    FastReader(){
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        st = new StringTokenizer("");
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    public static String next() throws IOException {
        while(!st.hasMoreElements() || st == null){
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}


import java.util.Scanner;

public class SolveTheMaze {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.next();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if(!findmaze(maze, n, m)){
                System.out.println("No");
        }
            else System.out.println("Yes");
    }

}

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = n-1; i >= 0; i--) {
            for (int j = m-1; j >= 0; j--) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] =-1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        for (int i = n-1; i >=0; i--) {
            for (int j = m-1; j >=0; j--) {
                if (maze[i][j] == 'G') {
                    if(check[i][j]==-1)
                        return false;

                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                }
            }
        }
//        for(int i=0;i<n;i++)
//            System.out.println(Arrays.toString(check[i]));
        return true;
    }

    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if(check[i][j]==-1)
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || j > m)
            return false;
//        System.out.println(i+" "+j);
        if (check[i][j] == -1)
            return false;
        //call 1
        if(check[i][j]==1) {
//            System.out.println("Yay");
            return true;
        }
        check[i][j] = -1;
        boolean v1 = findpath(check, i - 1, j, n, m);
        if(v1) {
            check[i][j]=1;
            return true;
        }
        boolean v2 = findpath(check, i + 1, j, n, m);
        if(v2) {
            check[i][j]=1;
            return true;
        }
        boolean v3 = findpath(check, i, j - 1, n, m);
        if(v3) {
           check[i][j]=1;
            return true;
        }
        boolean v4 = findpath(check, i, j + 1, n, m);
        if(v4) {
            check[i][j]=1;
            return true;
        }
        check[i][j]=0;
        return false;

    }

}