import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class SolveMaze {
  public static void main(String[] args) throws IOException {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(System.out);
    int t, n, m;
    boolean fnd;
    boolean[][] pth;
    char[][] mz;

    t = in.nextInt();
    while(t-- > 0) {
      n = in.nextInt();
      m = in.nextInt();
      mz = new char[n][];
      pth = new boolean[n][m];
      for (int i = 0; i < n; i++) mz[i] = in.next().toCharArray();
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (mz[i][j] == 'B') {
            if (i < n-1) if (mz[i+1][j] == '.') mz[i+1][j] = '#';
            if (j < m-1) if (mz[i][j+1] == '.') mz[i][j+1] = '#';
            if (i > 0) if (mz[i-1][j] == '.') mz[i-1][j] = '#';
            if (j > 0) if (mz[i][j-1] == '.') mz[i][j-1] = '#';
          }
        }
      }
      pth[n-1][m-1] = mz[n-1][m-1] == '#' ? false : true;
      for (int i = n-1; i >= 0; i--) {
        for (int j = m-1; j >= 0; j--) {
          if (i == n-1 && j == m-1) continue;
          if (mz[i][j] != '#') {
            if (i < n-1 && j < m - 1) pth[i][j] = pth[i+1][j] | pth[i][j+1];
            else if (i < n-1) pth[i][j] = pth[i+1][j];
            else if (j < m-1) pth[i][j] = pth[i][j+1];
          }
        }
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (i == n-1 && j == m-1) continue;
          if (mz[i][j] != '#' && !pth[i][j]) {
            if (i > 0 && j > 0) pth[i][j] = pth[i-1][j] | pth[i][j-1];
            else if (i > 0) pth[i][j] = pth[i-1][j];
            else if (j > 0) pth[i][j] = pth[i][j-1];
          }
        }
      }
      fnd = false;
      for (int i = 0; i < n; i++) {
        if (fnd) break;
        for (int j = 0; j < m; j++) {
          if (mz[i][j] == 'B' && pth[i][j]) { fnd = true; break; }
          else if (mz[i][j] == 'G' && !pth[i][j]) { fnd = true; break; }
        }
      }
      if (fnd) pw.println("No");
      else pw.println("Yes");
    }
    pw.close();
  }

  static class InputReader {
    BufferedReader br;
    StringTokenizer st;
    public InputReader(InputStream inputStream) {
      br = new BufferedReader(new InputStreamReader(inputStream));
      st = null;
    }

    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;
    }
  }
}