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

public class D {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(f.readLine());
        while(t-->0){
            StringTokenizer st = new StringTokenizer(f.readLine());
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            char[][] arr = new char[n][m];
            ArrayList<Point> good = new ArrayList<Point>();
            ArrayList<Point> bad = new ArrayList<Point>();
            for(int i = 0; i < n; i++){
                String str = f.readLine();
                for(int j = 0; j < m; j++){
                    arr[i][j] = str.charAt(j);
                    if(arr[i][j] == 'G') good.add(new Point(i, j));
                    if(arr[i][j] == 'B') bad.add(new Point(i, j));
                }
            }
            boolean goodV = true;
            LinkedList<Point> q = new LinkedList<Point>();
            for(Point point: bad) {
                q.add(new Point(point.r, point.c));
            }
                boolean[][] seen = new boolean[n][m];
                while(!q.isEmpty()){
                    Point temp = q.poll();
                    if(seen[temp.r][temp.c]) continue;
                    seen[temp.r][temp.c] = true;
                    if(temp.r == n-1 && temp.c == m-1){
                        goodV = false;
                        break;
                    }
                    if(temp.r != 0 && !seen[temp.r-1][temp.c]){
                        if(arr[temp.r-1][temp.c] == 'G' || arr[temp.r-1][temp.c] == 'B'){
                            q.add(new Point(temp.r-1, temp.c));
                        }else if(arr[temp.r-1][temp.c] == '.'){
                            arr[temp.r-1][temp.c] = '#';
                        }
                    }
                    if(temp.r != n-1 && !seen[temp.r+1][temp.c]){
                        if(arr[temp.r+1][temp.c] == 'G' || arr[temp.r+1][temp.c] == 'B'){
                            q.add(new Point(temp.r+1, temp.c));
                        }else if(arr[temp.r+1][temp.c] == '.'){
                            arr[temp.r+1][temp.c] = '#';
                        }
                    }
                    if(temp.c != 0 && !seen[temp.r][temp.c-1]){
                        if(arr[temp.r][temp.c-1] == 'G' || arr[temp.r][temp.c-1] == 'B'){
                            q.add(new Point(temp.r, temp.c-1));
                        }else if(arr[temp.r][temp.c-1] == '.'){
                            arr[temp.r][temp.c-1] = '#';
                        }
                    }
                    if(temp.c != m-1 && !seen[temp.r][temp.c+1]){
                        if(arr[temp.r][temp.c+1] == 'G' || arr[temp.r][temp.c+1] == 'B'){
                            q.add(new Point(temp.r, temp.c+1));
                        }else if(arr[temp.r][temp.c+1] == '.'){
                            arr[temp.r][temp.c+1] = '#';
                        }
                    }
                }

            if(!goodV){
                out.println("No");
                continue;
            }

            q = new LinkedList<Point>();
            seen = new boolean[n][m];
            q.add(new Point(n-1, m-1));
                while(!q.isEmpty()){
                    Point temp = q.poll();
                    if(arr[temp.r][temp.c] == '#' || seen[temp.r][temp.c]) continue;
                    seen[temp.r][temp.c] = true;
                    if(temp.r != 0 && arr[temp.r-1][temp.c] != '#' && !seen[temp.r-1][temp.c]){
                        q.add(new Point(temp.r-1, temp.c));
                    }
                    if(temp.r != n-1 && arr[temp.r+1][temp.c] != '#' && !seen[temp.r+1][temp.c]){
                        q.add(new Point(temp.r+1, temp.c));
                    }
                    if(temp.c != 0 && arr[temp.r][temp.c-1] != '#' && !seen[temp.r][temp.c-1]){
                        q.add(new Point(temp.r, temp.c-1));
                    }
                    if(temp.c != m-1 && arr[temp.r][temp.c+1] != '#' && !seen[temp.r][temp.c+1]){
                        q.add(new Point(temp.r, temp.c+1));
                    }

                }

            for(Point p: good) {
                if(!seen[p.r][p.c]){
                    goodV = false;
                    break;
                }
            }
            if(!goodV){
                out.println("No");
            }else{
                out.println("Yes");
            }
        }




        out.close();
    }
    static class Point{
        public int r;
        public int c;
        public Point(int r, int c){
            this.r=r;
            this.c=c;
        }
    }
}
