import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kraken7
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskD {

    private boolean[][] vis;
    private boolean[][] possible;
    private char[][] maze;
    private int n;
    private int m;

    private boolean safe(int x, int y) {
      if (x < 0 || x >= n || y < 0 || y >= m)
        return false;
      return maze[x][y] != '#';
    }

    private void dfs(int x, int y) {
      if (vis[x][y])
        return;
      vis[x][y] = true;
      possible[x][y] = false;

      if (safe(x + 1, y))
        possible[x][y] |= possible[x + 1][y];
      if (safe(x, y + 1))
        possible[x][y] |= possible[x][y + 1];
      if (safe(x - 1, y))
        possible[x][y] |= possible[x - 1][y];
      if (safe(x, y - 1))
        possible[x][y] |= possible[x][y - 1];

      if (safe(x - 1, y))
        dfs(x - 1, y);
      if (safe(x + 1, y))
        dfs(x + 1, y);
      if (safe(x, y - 1))
        dfs(x, y - 1);
      if (safe(x, y + 1))
        dfs(x, y + 1);
    }

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int t = in.nextInt();
      while (t-- > 0) {
        n = in.nextInt();
        m = in.nextInt();
        maze = new char[n][];
        vis = new boolean[n][m];
        possible = new boolean[n][m];
        for (int i = 0; i < n; i++)
          maze[i] = in.next().toCharArray();

        for (int i = 0; i < n; i++) {
          for (int j = 0; j < m; j++) {
            if (maze[i][j] == 'B') {
              // down
              if (safe(i + 1, j) && maze[i + 1][j] == '.')
                maze[i + 1][j] = '#';
              // up
              if (safe(i - 1, j) && maze[i - 1][j] == '.')
                maze[i - 1][j] = '#';
              // left
              if (safe(i, j - 1) && maze[i][j - 1] == '.')
                maze[i][j - 1] = '#';
              // right
              if (safe(i, j + 1) && maze[i][j + 1] == '.')
                maze[i][j + 1] = '#';
            }
          }
        }

        possible[n - 1][m - 1] = maze[n - 1][m - 1] != '#';
        vis[n - 1][m - 1] = true;
        if (safe(n - 1, m - 2))
          dfs(n - 1, m - 2);
        if (safe(n - 2, m - 1))
          dfs(n - 2, m - 1);

        //      for (boolean[] i : possible) out.println(Arrays.toString(i));

        boolean fine = true;
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < m; j++) {
            if (safe(i, j - 1) && ((maze[i][j] == 'G' && maze[i][j - 1] == 'B') || (maze[i][j] == 'B'
              && maze[i][j - 1] == 'G'))) {
              fine = false;
              break;
            }
            if (safe(i - 1, j) && ((maze[i][j] == 'G' && maze[i - 1][j] == 'B') || (maze[i][j] == 'B'
              && maze[i - 1][j] == 'G'))) {
              fine = false;
              break;
            }
          }
          if (!fine)
            break;
        }
        for (int i = 0; i < n; i++) {
          for (int j = 0; j < m; j++) {
            if (maze[i][j] == 'G' && !possible[i][j]) {
              fine = false;
              break;
            }
          }
          if (!fine)
            break;
        }

        out.println(fine ? "Yes" : "No");
      }
    }

  }
}

