
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class D {

  public static void main(String[] args) throws Exception {
    new D().go();
  }
  static boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;


  Scanner in;
  //  String INPUT = "6\r\n" +
  //      "1 1\r\n" +
  //      ".\r\n" +
  //      "1 2\r\n" +
  //      "G.\r\n" +
  //      "2 2\r\n" +
  //      "#B\r\n" +
  //      "G.\r\n" +
  //      "2 3\r\n" +
  //      "G.#\r\n" +
  //      "B#.\r\n" +
  //      "3 3\r\n" +
  //      "#B.\r\n" +
  //      "#..\r\n" +
  //      "GG.\r\n" +
  //      "2 2\r\n" +
  //      "#B\r\n" +
  //      "B.";


  String INPUT = "1\r\n" +
      "4 6\r\n" +
      "....##\r\n" +
      ".#.G.#\r\n" +
      ".#....\r\n" +
      ".#..#.";


  void go() {
    if (LOCAL) {
      System.setIn(new ByteArrayInputStream(INPUT.getBytes()));
    }
    in = new Scanner(System.in);
    long startTime = System.currentTimeMillis();
    solve();
    if (LOCAL) {
      System.out.printf("[%dms]", System.currentTimeMillis()-startTime);
    }
    in.close();
  }


  PrintWriter out = new PrintWriter(System.out);
  StringBuffer sb = new StringBuffer();

  void solve() {
    int t = in.nextInt();
    for (int i=1; i<=t; i++) {
      solve2(i);
    }

    out.flush();
  } // end of solve



  void solve2(int caseNr) {

    int n = in.nextInt()+2;
    int m = in.nextInt()+2;
    char[][] maze = new char[n][m];

    for (int i=1; i<n-1; i++) {
      String next_line = in.next();
      for (int j = 1; j<m-1; j++) {
        maze[i][j] = next_line.charAt(j-1);
      }
    }

    for (int i = 0; i < n; i++) {
      maze[i][0] = '#';
      maze[i][m-1] = '#';
    }
    for (int j = 0; j < m; j++) {
      maze[0][j] = '#';
      maze[n-1][j] = '#';
    }


    // ZZ.showIntegerArray(r);
    // if (caseNr != 5) return;


    //    .
    //
    //    G    .
    //
    //    #    B
    //    G    .
    //
    //    G    .    #
    //    B    #    .
    //
    //    #    B    .
    //    #    .    .
    //    G    G    .
    //
    //    #    B
    //    B    .

    //    for (int i=0; i<n; i++) {
    //      for (int j = 0; j <m; j++) {
    //        System.out.print(maze[i][j] + "    ");
    //      }
    //      System.out.println();
    //    }
    //    System.out.println();



    // WE CLEAR FROM
    // System.out.println(maze[n-2][m-2]);
    int nr_good = 0;

    for (int i=0; i<n; i++) {
      for (int j = 0; j<m; j++) {
        if (maze[i][j] == 'G') {
          nr_good++;
        }
        if (maze[i][j] == 'B') {
          if (maze[i-1][j] == 'G' || maze[i+1][j] == 'G' || maze[i][j-1] == 'G' || maze[i][j+1] == 'G') {
            System.out.println("No");
            return;
          }
          maze[i-1][j] = '#';
          maze[i+1][j] = '#';
          maze[i][j-1] = '#';
          maze[i][j+1] = '#';
        }
      }
    }


    if (nr_good == 0) {
      System.out.println("Yes");
      return;
    }


    //    #    #    #    #    #
    //    #    #    B    #    #
    //    #    #    #    .    #
    //    #    G    G    .    #
    //    #    #    #    #    #

    if (maze[n-2][m-2] == '#') {
      System.out.println("No");
      return;
    }

    //    for (int i=0; i<n; i++) {
    //      for (int j = 0; j <m; j++) {
    //        System.out.print(maze[i][j] + "    ");
    //      }
    //      System.out.println();
    //    }
    //    System.out.println();


    expand(maze, n-2, m-2);

    for (int i=0; i<n; i++) {
      for (int j = 0; j<m; j++) {
        if (maze[i][j] == 'G') {
          System.out.println("No");
          return;
        }
      }
    }

    System.out.println("Yes");

  } // end of solve2



  void expand(char[][] maze, int i, int j) {
    if (maze[i][j] != '.' && maze[i][j] != 'G') {
      return;
    }

    maze[i][j] = '#';
    expand(maze, i-1, j);
    expand(maze, i+1, j);
    expand(maze, i, j-1);
    expand(maze, i, j+1);
  }




}






