
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static char array[][];
    private static int num;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int t = scan.nextInt();

        while( t-- > 0 ) {
            int n = scan.nextInt(), m = scan.nextInt();
            array = new char[n][m];

            LinkedList<int[]> bads = new LinkedList<>();
            num = 0;

            for(int i=0;i<n;i++) {
                String loc = scan.next();
                for(int j=0;j<m;j++) {
                    array[i][j] = loc.charAt(j);
                    if(loc.charAt(j) == 'G') {
                        num++;
                    } else if(loc.charAt(j) == 'B') {
                        bads.add(new int[] {i,j});
                    }
                }
            }


            //walling
            boolean end = false;
            for(int[] bad : bads) {
                int i = bad[0], j = bad[1];
                if(i > 0) {
                    if(array[i-1][j] == 'G') {
                        end = true;
                        break;
                    }
                    if(array[i-1][j] != 'B') {
                        array[i-1][j] = '#';
                    }
                }
                if(j > 0) {
                    if(array[i][j-1] == 'G') {
                        end = true;
                        break;
                    }
                    if(array[i][j-1] != 'B') {
                        array[i][j-1] = '#';
                    }
                }

                if(i < n-1) {
                    if(array[i+1][j] == 'G') {
                        end = true;
                        break;
                    }
                    if(array[i+1][j] != 'B') {
                        array[i+1][j] = '#';
                    }
                }

                if(j < m-1) {
                    if(array[i][j+1] == 'G') {
                        end = true;
                        break;
                    }
                    if(array[i][j+1] != 'B') {
                        array[i][j+1] = '#';
                    }
                }
            }


            if(end) {
                System.out.println("No");
                continue;
            }

            rek(n-1,m-1);

            if(num == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

        }

    }

    private static void rek(int i, int j) {
        if(num == 0 || i < 0 || j < 0 || array[i][j] == '#') {
            return;
        }

        if(array[i][j] == 'G') {
            num--;
        }

        array[i][j] = '#';
        rek(i-1,j);
        rek(i,j-1);
    }
}
