import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class SolveTheMaze {
    static class Print {
        private final OutputStream out;

        /*public Print(OutputStream outputStream)
        {
            writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }*/
        public Print() {
            this.out = System.out;
        }

        public void print(String str) throws IOException {
            //buf=str.getBytes();
            for (int i = 0; i < str.length(); i++) {
			/*if (i != 0)
			out.write(' ');*/
                out.write(str.charAt(i));
            }
        }

        public void printLine(String str) throws IOException {
            print(str);
            out.write('\n');
        }

        public void close() throws IOException {
            out.close();
        }
    }

    static class Scan {
        private byte[] buf = new byte[1024];
        private int index;
        private InputStream in;
        private int total;

        public Scan() {
            in = System.in;
        }

        public int scan() throws IOException {
            if (total < 0)
                throw new InputMismatchException();
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0)
                    return -1;
            }
            return buf[index++];
        }

        public int scanInt() throws IOException {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            return neg * integer;
        }

        public double scanDouble() throws IOException {
            double doub = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n) && n != '.') {
                if (n >= '0' && n <= '9') {
                    doub *= 10;
                    doub += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            if (n == '.') {
                n = scan();
                double temp = 1;
                while (!isWhiteSpace(n)) {
                    if (n >= '0' && n <= '9') {
                        temp /= 10;
                        doub += (n - '0') * temp;
                        n = scan();
                    } else throw new InputMismatchException();
                }
            }
            return doub * neg;
        }

        public String scanString() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            while (!isWhiteSpace(n)) {
                sb.append((char) n);
                n = scan();
            }
            return sb.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                return true;
            return false;
        }
    }

    public static void main(String[] args) throws IOException {
//        Scanner scn = new Scanner(System.in);
        Scan scn = new Scan();
        Print print = new Print();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = scn.scanInt();
        while (t-- > 0) {
            int n = scn.scanInt();
            int m = scn.scanInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.scanString();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if (!findmaze(maze, n, m)) {
                bw.append("No\n");
            } else bw.append("Yes\n");
        }
        bw.close();
    }

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] = -1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        dfs(check,n-1,m-1);
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if(maze[i][j]=='G'){
                    if(check[i][j]==0 || check[i][j]==-1)
                        return false;
                }
//                if (maze[i][j] == 'G') {
//                    if (check[i][j] == -1)
//                        return false;
//
//                    if (!findpath(check, i, j, n - 1, m - 1))
//                        return false;
//                    else check[i][j] = 1;

            }
        }
        for(int i=0;i<n;i++)
            System.out.println(Arrays.toString(check[i]));
        return true;
    }
    public static void dfs(int[][] user,int i,int j) {
        if(i==user.length || i==-1 || j==-1 || j==user[0].length)
            return;
        if(user[i][j]==-1)
            return;
        if(user[i][j]==1)
            return;
        user[i][j]=1;
        dfs(user,i+1,j);
        dfs(user,i-1,j);
        dfs(user,i,j+1);
        dfs(user,i,j-1);
    }
//    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
//        if (i == n && j == m) {
//            if (check[i][j] == -1)
//                return false;
//            return true;
//        }
//        if (i < 0 || j < 0)
//            return false;
//        if (i > n || j > m)
//            return false;
////        System.out.println(i+" "+j);
//        if (check[i][j] == -1)
//            return false;
//        //call 1
//        if (check[i][j] == 1) {
////            System.out.println("Yay");
//            return true;
//        }
//        check[i][j] = -1;
//        boolean v4 = findpath(check, i, j + 1, n, m);
//        if (v4) {
//            check[i][j] = 1;
//            return true;
//        }
//        boolean v2 = findpath(check, i + 1, j, n, m);
//        if (v2) {
//            check[i][j] = 1;
//            return true;
//        }
//        boolean v1 = findpath(check, i - 1, j, n, m);
//        if (v1) {
//            check[i][j] = 1;
//            return true;
//        }
//
//        boolean v3 = findpath(check, i, j - 1, n, m);
//        if (v3) {
//            check[i][j] = 1;
//            return true;
//        }
//
//        check[i][j] = 0;
//        return false;
//
//    }

}


import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class SolveTheMaze {
    static class Print {
        private final OutputStream out;

        /*public Print(OutputStream outputStream)
        {
            writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }*/
        public Print() {
            this.out = System.out;
        }

        public void print(String str) throws IOException {
            //buf=str.getBytes();
            for (int i = 0; i < str.length(); i++) {
			/*if (i != 0)
			out.write(' ');*/
                out.write(str.charAt(i));
            }
        }

        public void printLine(String str) throws IOException {
            print(str);
            out.write('\n');
        }

        public void close() throws IOException {
            out.close();
        }
    }

    static class Scan {
        private byte[] buf = new byte[1024];
        private int index;
        private InputStream in;
        private int total;

        public Scan() {
            in = System.in;
        }

        public int scan() throws IOException {
            if (total < 0)
                throw new InputMismatchException();
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0)
                    return -1;
            }
            return buf[index++];
        }

        public int scanInt() throws IOException {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            return neg * integer;
        }

        public double scanDouble() throws IOException {
            double doub = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n) && n != '.') {
                if (n >= '0' && n <= '9') {
                    doub *= 10;
                    doub += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            if (n == '.') {
                n = scan();
                double temp = 1;
                while (!isWhiteSpace(n)) {
                    if (n >= '0' && n <= '9') {
                        temp /= 10;
                        doub += (n - '0') * temp;
                        n = scan();
                    } else throw new InputMismatchException();
                }
            }
            return doub * neg;
        }

        public String scanString() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            while (!isWhiteSpace(n)) {
                sb.append((char) n);
                n = scan();
            }
            return sb.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                return true;
            return false;
        }
    }

    public static void main(String[] args) throws IOException {
//        Scanner scn = new Scanner(System.in);
        Scan scn = new Scan();
        Print print = new Print();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = scn.scanInt();
        while (t-- > 0) {
            int n = scn.scanInt();
            int m = scn.scanInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.scanString();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if (!findmaze(maze, n, m)) {
                bw.append("No\n");
            } else bw.append("Yes\n");
        }
        bw.close();
    }

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] = -1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        dfs(check,n-1,m-1);
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if(maze[i][j]=='G'){
                    if(check[i][j]==0 || check[i][j]==-1)
                        return false;
                }
//                if (maze[i][j] == 'G') {
//                    if (check[i][j] == -1)
//                        return false;
//
//                    if (!findpath(check, i, j, n - 1, m - 1))
//                        return false;
//                    else check[i][j] = 1;

            }
        }
//        for(int i=0;i<n;i++)
//            System.out.println(Arrays.toString(check[i]));
        return true;
    }
    public static void dfs(int[][] user,int i,int j) {
        if(i==user.length || i==-1 || j==-1 || j==user[0].length)
            return;
        if(user[i][j]==-1)
            return;
        if(user[i][j]==1)
            return;
        user[i][j]=1;
        dfs(user,i+1,j);
        dfs(user,i-1,j);
        dfs(user,i,j+1);
        dfs(user,i,j-1);
    }
//    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
//        if (i == n && j == m) {
//            if (check[i][j] == -1)
//                return false;
//            return true;
//        }
//        if (i < 0 || j < 0)
//            return false;
//        if (i > n || j > m)
//            return false;
////        System.out.println(i+" "+j);
//        if (check[i][j] == -1)
//            return false;
//        //call 1
//        if (check[i][j] == 1) {
////            System.out.println("Yay");
//            return true;
//        }
//        check[i][j] = -1;
//        boolean v4 = findpath(check, i, j + 1, n, m);
//        if (v4) {
//            check[i][j] = 1;
//            return true;
//        }
//        boolean v2 = findpath(check, i + 1, j, n, m);
//        if (v2) {
//            check[i][j] = 1;
//            return true;
//        }
//        boolean v1 = findpath(check, i - 1, j, n, m);
//        if (v1) {
//            check[i][j] = 1;
//            return true;
//        }
//
//        boolean v3 = findpath(check, i, j - 1, n, m);
//        if (v3) {
//            check[i][j] = 1;
//            return true;
//        }
//
//        check[i][j] = 0;
//        return false;
//
//    }

}


import java.io.*;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class SolveTheMaze {
    static class Print {
        private final OutputStream out;

        /*public Print(OutputStream outputStream)
        {
            writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }*/
        public Print() {
            this.out = System.out;
        }

        public void print(String str) throws IOException {
            //buf=str.getBytes();
            for (int i = 0; i < str.length(); i++) {
			/*if (i != 0)
			out.write(' ');*/
                out.write(str.charAt(i));
            }
        }

        public void printLine(String str) throws IOException {
            print(str);
            out.write('\n');
        }

        public void close() throws IOException {
            out.close();
        }
    }

    static class Scan {
        private byte[] buf = new byte[1024];
        private int index;
        private InputStream in;
        private int total;

        public Scan() {
            in = System.in;
        }

        public int scan() throws IOException {
            if (total < 0)
                throw new InputMismatchException();
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0)
                    return -1;
            }
            return buf[index++];
        }

        public int scanInt() throws IOException {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            return neg * integer;
        }

        public double scanDouble() throws IOException {
            double doub = 0;
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n) && n != '.') {
                if (n >= '0' && n <= '9') {
                    doub *= 10;
                    doub += n - '0';
                    n = scan();
                } else throw new InputMismatchException();
            }
            if (n == '.') {
                n = scan();
                double temp = 1;
                while (!isWhiteSpace(n)) {
                    if (n >= '0' && n <= '9') {
                        temp /= 10;
                        doub += (n - '0') * temp;
                        n = scan();
                    } else throw new InputMismatchException();
                }
            }
            return doub * neg;
        }

        public String scanString() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = scan();
            while (isWhiteSpace(n))
                n = scan();
            while (!isWhiteSpace(n)) {
                sb.append((char) n);
                n = scan();
            }
            return sb.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                return true;
            return false;
        }
    }

    public static void main(String[] args) throws IOException {
//        Scanner scn = new Scanner(System.in);
        Scan scn = new Scan();
        Print print = new Print();
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = scn.scanInt();
        while (t-- > 0) {
            int n = scn.scanInt();
            int m = scn.scanInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.scanString();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if (!findmaze(maze, n, m)) {
                bw.append("No\n");
            } else bw.append("Yes\n");
        }
        bw.close();
    }

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] = -1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        for (int i = n - 1; i >= 0; i--) {
            for (int j = m - 1; j >= 0; j--) {
                if (maze[i][j] == 'G') {
                    if (check[i][j] == -1)
                        return false;

                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                    else check[i][j] = 1;
                }
            }
        }
//        for(int i=0;i<n;i++)
//            System.out.println(Arrays.toString(check[i]));
        return true;
    }

    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if (check[i][j] == -1)
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || j > m)
            return false;
//        System.out.println(i+" "+j);
        if (check[i][j] == -1)
            return false;
        //call 1
        if (check[i][j] == 1) {
//            System.out.println("Yay");
            return true;
        }
        check[i][j] = -1;
        boolean v4 = findpath(check, i, j + 1, n, m);
        if (v4) {
            check[i][j] = 1;
            return true;
        }
        boolean v2 = findpath(check, i + 1, j, n, m);
        if (v2) {
            check[i][j] = 1;
            return true;
        }
        boolean v1 = findpath(check, i - 1, j, n, m);
        if (v1) {
            check[i][j] = 1;
            return true;
        }

        boolean v3 = findpath(check, i, j - 1, n, m);
        if (v3) {
            check[i][j] = 1;
            return true;
        }

        check[i][j] = 0;
        return false;

    }

}


import java.util.Scanner;

public class SolveTheMaze {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.next();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if(!findmaze(maze, n, m)){
                System.out.println("No");
        }
            else System.out.println("Yes");
    }

}

    public static boolean findmaze(char[][] maze, int n, int m) {
        boolean[][] check = new boolean[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'B') {
                    check[i][j] = true;
                    if (i > 0)
                        check[i - 1][j] = true;
                    if (i < n - 1)
                        check[i + 1][j] = true;
                    if (j < m - 1)
                        check[i][j + 1] = true;
                    if (j > 0)
                        check[i][j - 1] = true;
                } else if (maze[i][j] == '#')
                    check[i][j] = true;

            }

        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'G') {
                    if(check[i][j])
                        return false;
                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                }
            }
        }
        return true;
    }

    public static boolean findpath(boolean[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if(check[i][j])
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || j > m)
            return false;
//        System.out.println(i+" "+j);
        if (check[i][j] == true)
            return false;
        //call 1
        check[i][j] = true;
        boolean v1 = findpath(check, i - 1, j, n, m);
        boolean v2 = findpath(check, i + 1, j, n, m);
        boolean v3 = findpath(check, i, j - 1, n, m);
        boolean v4 = findpath(check, i, j + 1, n, m);
        check[i][j] = false;
        return v1 || v2 || v3 || v4;

    }

}


import java.util.Scanner;

public class SolveTheMaze {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.next();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if(!findmaze(maze, n, m)){
                System.out.println("No");
        }
            else System.out.println("Yes");
    }

}

    public static boolean findmaze(char[][] maze, int n, int m) {
        boolean[][] check = new boolean[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'B') {
                    check[i][j] = true;
                    if (i > 0)
                        check[i - 1][j] = true;
                    if (i < n - 1)
                        check[i + 1][j] = true;
                    if (j < m - 1)
                        check[i][j + 1] = true;
                    if (j > 0)
                        check[i][j - 1] = true;
                } else if (maze[i][j] == '#')
                    check[i][j] = true;

            }

        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'G') {
                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                }
            }
        }
        return true;
    }

    public static boolean findpath(boolean[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if(check[i][j])
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || i > m)
            return false;
        if (check[i][j] == true)
            return false;
        //call 1
        check[i][j] = true;
        boolean v1 = findpath(check, i - 1, j, n, m);
        boolean v2 = findpath(check, i + 1, j, n, m);
        boolean v3 = findpath(check, i, j - 1, n, m);
        boolean v4 = findpath(check, i, j + 1, n, m);
        check[i][j] = false;
        return v1 || v2 || v3 || v4;

    }

}


import java.util.Scanner;

public class SolveTheMaze {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.next();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if(!findmaze(maze, n, m)){
                System.out.println("No");
        }
            else System.out.println("Yes");
    }

}

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] =-1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == 'G') {
                    if(check[i][j]==-1)
                        return false;
                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                }
            }
        }
//        for(int i=0;i<n;i++)
//            System.out.println(Arrays.toString(check[i]));
        return true;
    }

    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if(check[i][j]==-1)
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || j > m)
            return false;
//        System.out.println(i+" "+j);
        if (check[i][j] == -1)
            return false;
        //call 1
        if(check[i][j]==1)
            return true;
        check[i][j] = -1;
        boolean v1 = findpath(check, i - 1, j, n, m);
        if(v1) {
            check[i][j]=1;
            return true;
        }
        boolean v2 = findpath(check, i + 1, j, n, m);
        if(v2) {
            check[i][j]=1;
            return true;
        }
        boolean v3 = findpath(check, i, j - 1, n, m);
        if(v3) {
           check[i][j]=1;
            return true;
        }
        boolean v4 = findpath(check, i, j + 1, n, m);
        if(v4) {
            check[i][j]=1;
            return true;
        }
        check[i][j]=0;
        return false;

    }

}


import java.util.Scanner;

public class SolveTheMaze {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int t = scn.nextInt();
        while (t-- > 0) {
            int n = scn.nextInt();
            int m = scn.nextInt();
            char[][] maze = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = scn.next();
                for (int j = 0; j < m; j++) {
                    maze[i][j] = s.charAt(j);
                }
            }
            if(!findmaze(maze, n, m)){
                System.out.println("No");
        }
            else System.out.println("Yes");
    }

}

    public static boolean findmaze(char[][] maze, int n, int m) {
        int[][] check = new int[n][m];
        for (int i = n-1; i >= 0; i--) {
            for (int j = m-1; j >= 0; j--) {
                if (maze[i][j] == 'B') {
                    check[i][j] = -1;
                    if (i > 0)
                        check[i - 1][j] = -1;
                    if (i < n - 1)
                        check[i + 1][j] = -1;
                    if (j < m - 1)
                        check[i][j + 1] =-1;
                    if (j > 0)
                        check[i][j - 1] = -1;
                } else if (maze[i][j] == '#')
                    check[i][j] = -1;

            }

        }
        for (int i = n-1; i >=0; i--) {
            for (int j = m-1; j >=0; j--) {
                if (maze[i][j] == 'G') {
                    if(check[i][j]==-1)
                        return false;

                    if (!findpath(check, i, j, n - 1, m - 1))
                        return false;
                    else check[i][j]=1;
                }
            }
        }
//        for(int i=0;i<n;i++)
//            System.out.println(Arrays.toString(check[i]));
        return true;
    }

    public static boolean findpath(int[][] check, int i, int j, int n, int m) {
        if (i == n && j == m) {
            if(check[i][j]==-1)
                return false;
            return true;
        }
        if (i < 0 || j < 0)
            return false;
        if (i > n || j > m)
            return false;
//        System.out.println(i+" "+j);
        if (check[i][j] == -1)
            return false;
        //call 1
        if(check[i][j]==1) {
//            System.out.println("Yay");
            return true;
        }
        check[i][j] = -1;
        boolean v4 = findpath(check, i, j + 1, n, m);
        if(v4) {
            check[i][j]=1;
            return true;
        }
        boolean v2 = findpath(check, i + 1, j, n, m);
        if(v2) {
            check[i][j]=1;
            return true;
        }
        boolean v1 = findpath(check, i - 1, j, n, m);
        if(v1) {
            check[i][j]=1;
            return true;
        }

        boolean v3 = findpath(check, i, j - 1, n, m);
        if(v3) {
           check[i][j]=1;
            return true;
        }

        check[i][j]=0;
        return false;

    }

}


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

  }
}


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 (maze[i][j] == 'G' && !possible[i][j]) {
              fine = false;
              break;
            }
          }
          if (!fine)
            break;
        }

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

  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class ProblemD {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

    public static void main(String[] args) {
        FastReader scanner = new FastReader();

        int t = scanner.nextInt();

        for (int testCase = 0; testCase < t; testCase++) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();

            int amountGoodPeopleStart = 0;

            char[][] grid = new char[n][m];
            for (int i = 0; i < n; i++) {
                grid[i] = scanner.next().toCharArray();
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] == 'G') {
                        amountGoodPeopleStart++;
                    }
                }
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] == 'B') {
                        grid[i][j] = '#';
                        if (i > 0) {
                            grid[i - 1][j] = '#';
                        }
                        if (j > 0) {
                            grid[i][j - 1] = '#';
                        }
                        if (i + 1 < n && grid[i+1][j] != 'B') {
                            grid[i + 1][j] = '#';
                        }
                        if (j + 1 < m && grid[i][j+1] != 'B') {
                            grid[i][j + 1] = '#';
                        }
                    }
                }
            }

            int amountGoodPeopleEnd = 0;
            boolean allGoodPeopleFindExit = true;
            boolean[][] findExitFromHere = new boolean[n][m];
            findExitPositions(grid, findExitFromHere, n - 1, m - 1);

            for (int i = 0; i < n && allGoodPeopleFindExit; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] == 'G') {
                        amountGoodPeopleEnd++;
                        if (!findExitFromHere[i][j]) {
                            allGoodPeopleFindExit = false;
                            break;
                        }
                    }
                }
            }

            if (amountGoodPeopleStart == amountGoodPeopleEnd && allGoodPeopleFindExit) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static void findExitPositions(char[][] grid, boolean[][] findExitFromHere, int row, int col) {
        if (col < 0 || row < 0 || row >= grid.length || col >= grid[row].length || findExitFromHere[row][col] || grid[row][col] == '#') {
            return;
        }

        findExitFromHere[row][col] = true;

        findExitPositions(grid, findExitFromHere, row + 1, col);
        findExitPositions(grid, findExitFromHere, row - 1, col);
        findExitPositions(grid, findExitFromHere, row, col + 1);
        findExitPositions(grid, findExitFromHere, row, col - 1);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class ProblemD {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

    public static void main(String[] args) {
        FastReader scanner = new FastReader();

        int t = scanner.nextInt();

        for (int testCase = 0; testCase < t; testCase++) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();

            int amountGoodPeopleStart = 0;

            char[][] grid = new char[n][m];
            for (int i = 0; i < n; i++) {
                grid[i] = scanner.next().toCharArray();
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] == 'G') {
                        amountGoodPeopleStart++;
                    }
                }
            }

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

            int amountGoodPeopleEnd = 0;
            boolean allGoodPeopleFindExit = true;
            boolean[][] findExitFromHere = new boolean[n][m];
            findExitPositions(grid, findExitFromHere, n - 1, m - 1);

            for (int i = 0; i < n && allGoodPeopleFindExit; i++) {
                for (int j = 0; j < m; j++) {
                    if (grid[i][j] == 'G') {
                        amountGoodPeopleEnd++;
                        if (!findExitFromHere[i][j]) {
                            allGoodPeopleFindExit = false;
                            break;
                        }
                    }
                }
            }

            if (amountGoodPeopleStart == amountGoodPeopleEnd && allGoodPeopleFindExit) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static void findExitPositions(char[][] grid, boolean[][] findExitFromHere, int row, int col) {
        if (col < 0 || row < 0 || row >= grid.length || col >= grid[row].length || findExitFromHere[row][col] || grid[row][col] == '#') {
            return;
        }

        findExitFromHere[row][col] = true;

        findExitPositions(grid, findExitFromHere, row + 1, col);
        findExitPositions(grid, findExitFromHere, row - 1, col);
        findExitPositions(grid, findExitFromHere, row, col + 1);
        findExitPositions(grid, findExitFromHere, row, col - 1);
    }
}


// Imports
import java.util.*;
import java.io.*;

public class D1365 {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {

        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        // BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));

        // TODO code application logic here
        int T = Integer.parseInt(f.readLine());
        for(int i = 0; i < T; i++) {
            StringTokenizer st = new StringTokenizer(f.readLine());
            int N = Integer.parseInt(st.nextToken());
            int M = Integer.parseInt(st.nextToken());

            int[][] arr = new int[N][M];
            boolean[][] visited = new boolean[N][M];
            int goodcount = 0;
            Queue<Integer> badpeople = new ArrayDeque<>();
            for(int j = 0; j < N; j++) {
                String current = f.readLine();
                for(int k = 0; k < M; k++) {
                    switch(current.charAt(k)) {
                        case '#':
                            arr[j][k] = 1;
                            break;
                        case 'G':
                            arr[j][k] = 2;
                            goodcount++;
                            break;
                        case 'B':
                            arr[j][k] = 3;
                            // mark for blockage
                            badpeople.add(j*M + k);
                            break;
                    }
                }
            }

            // System.out.println(Arrays.deepToString(arr));
            while(!badpeople.isEmpty()) {
                int curr = badpeople.poll();
                int x = curr/M;
                int y = curr%M;

                int[] dx = {-1, 0, 1, 0};
                int[] dy = {0, -1, 0, 1};

                for(int j = 0; j < dx.length; j++) {
                    int newx = x + dx[j];
                    int newy = y + dy[j];

                    if(newx >= 0 && newy >= 0 && newx < N && newy < M && arr[newx][newy] == 0) {
                        arr[newx][newy] = 1;
                    }
                }
            }
            // System.out.println(Arrays.deepToString(arr));

            Queue<Integer> bfs = new ArrayDeque<>();
            int goodencountered = 0;
            boolean badencountered = false;
            if(arr[N - 1][M - 1] == 0) {
                bfs.add(N*M - 1);
                visited[N - 1][M - 1] = true;
            }

            while(!bfs.isEmpty()) {
                int curr = bfs.poll();
                int x = curr/M;
                int y = curr%M;
                // System.out.println(x + " " + y + " " + goodencountered + " " + badencountered);

                int[] dx = {-1, 0, 1, 0};
                int[] dy = {0, -1, 0, 1};

                for(int j = 0; j < dx.length; j++) {
                    int newx = x + dx[j];
                    int newy = y + dy[j];

                    if(newx >= 0 && newy >= 0 && newx < N && newy < M && arr[newx][newy] != 1
                            && !visited[newx][newy]) {
                        visited[newx][newy] = true;
                        bfs.add(newx*M + newy);
                        if(arr[newx][newy] == 3) {
                            badencountered = true;
                            break;
                        }
                        else if(arr[newx][newy] == 2) {
                            goodencountered++;
                        }
                    }
                }

                if(badencountered) {
                    break;
                }
            }

            // System.out.println(badencountered + " " + goodencountered + " " + goodcount);
            if(!badencountered && goodencountered == goodcount) {
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
    }

}


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

public class Solution {
	static class Reader {
		BufferedReader br;
		StringTokenizer st;

		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

	public static void main(String[] args) {
		Reader r = new Reader();

		int t = r.nextInt();

		for (int i = 0; i < t; i++) {
			int n = r.nextInt();
			int m = r.nextInt();
			int[][] g = new int[n][m];
			ArrayList<Integer> good = new ArrayList<Integer>();

			for (int j = 0; j < n; j++) {
				String s = r.next();
				for (int k = 0; k < m; k++) {
					char c = s.charAt(k);

					if (c == '.') g[j][k] = 1;
					else if (c == '#') g[j][k] = 2;
					else if (c == 'G') {
						g[j][k] = 3;
						good.add(j); good.add(k);
					} else g[j][k] = 4;
				}
			}

			boolean pos = true;
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < m; k++) {
					if (g[j][k] == 4) {
						if (j > 0 && g[j - 1][k] < 3) g[j - 1][k] = 2;
						if (k > 0 && g[j][k - 1] < 3) g[j][k - 1] = 2;
						if (j < n - 1 && g[j + 1][k] < 3) g[j + 1][k] = 2;
						if (k < m - 1 && g[j][k + 1] < 3) g[j][k + 1] = 2;
					}
				}
			}

			LinkedList<Integer> list = new LinkedList<Integer>();
			list.add(n - 1);
			list.add(m - 1);
			boolean[][] vis = new boolean[n][m];
			int found = 0;

			while (!list.isEmpty()) {
				int x = list.pop();
				int c = list.pop();

				if (!vis[x][c] && g[x][c] != 2) {
					vis[x][c] = true;
					if (g[x][c] == 3) found++;
					else if (g[x][c] == 4) found = Integer.MIN_VALUE;
					if (x > 0 && !vis[x - 1][c]) {
						list.add(x - 1);
						list.add(c);
					}
					if (c > 0 && !vis[x][c - 1]) {
						list.add(x);
						list.add(c - 1);
					}
					if (x < n - 1 && !vis[x + 1][c]) {
						list.add(x + 1);
						list.add(c);
					}
					if (c < m - 1 && !vis[x][c + 1]) {
						list.add(x);
						list.add(c + 1);
					}
				}
			}

			if (found == (good.size() / 2)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		}

	}
}


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

public class Solution {
	static class Reader {
		BufferedReader br;
		StringTokenizer st;

		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

	public static void main(String[] args) {
		Reader r = new Reader();

		int t = r.nextInt();

		for (int i = 0; i < t; i++) {
			int n = r.nextInt();
			int m = r.nextInt();
			int[][] g = new int[n][m];
			ArrayList<Integer> good = new ArrayList<Integer>();

			for (int j = 0; j < n; j++) {
				String s = r.next();
				for (int k = 0; k < m; k++) {
					char c = s.charAt(k);

					if (c == '.') g[j][k] = 1;
					else if (c == '#') g[j][k] = 2;
					else if (c == 'G') {
						g[j][k] = 3;
						good.add(j); good.add(k);
					} else g[j][k] = 4;
				}
			}

			boolean pos = true;
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < m; k++) {
					if (g[j][k] == 4) {
						if (j > 0 && g[j - 1][k] < 3) g[j - 1][k] = 2;
						if (k > 0 && g[j][k - 1] < 3) g[j][k - 1] = 2;
						if (j < n - 1 && g[j + 1][k] < 3) g[j + 1][k] = 2;
						if (k < m - 1 && g[j][k + 1] < 3) g[j][k + 1] = 2;
					}
				}
			}

			LinkedList<Integer> list = new LinkedList<Integer>();
			list.add(n - 1);
			list.add(m - 1);
			boolean[][] vis = new boolean[n][m];
			int found = 0;

			while (!list.isEmpty()) {
				int x = list.pop();
				int c = list.pop();

				if (!vis[x][c] && g[x][c] != 2) {
					vis[x][c] = true;
					if (g[x][c] == 3) found++;
					if (x > 0 && !vis[x - 1][c]) {
						list.add(x - 1);
						list.add(c);
					}
					if (c > 0 && !vis[x][c - 1]) {
						list.add(x);
						list.add(c - 1);
					}
					if (x < n - 1 && !vis[x + 1][c]) {
						list.add(x + 1);
						list.add(c);
					}
					if (c < m - 1 && !vis[x][c + 1]) {
						list.add(x);
						list.add(c + 1);
					}
				}
			}

			if (found == (good.size() / 2)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		}

	}
}


import java.util.ArrayDeque;
import java.util.Scanner;

public class cf1365_Div2_D {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int tc = in.nextInt();
		for ( ; tc > 0; tc--) {
			int n = in.nextInt();
			int m = in.nextInt();
			char[][] grid = new char[n][m];

			int[] dx = {0,0,1,-1};
			int[] dy = {1,-1,0,0};
			int whites = 0;

			for (int i = 0; i < n; i++) {
				grid[i] = in.next().toCharArray();
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (grid[i][j] == 'B') {
						for (int k = 0; k < 4; k++) {
							int x = dx[k] + i;
							int y = dy[k] + j;
							if (x < n && x >= 0 && y < m && y >= 0 && grid[x][y] == '.') {
								grid[x][y] = '#';
							}
						}
					}
					else if (grid[i][j] == 'G')
						whites++;
				}
			}

			ArrayDeque<Integer[]> q = new ArrayDeque<Integer[]>();
			boolean[][] visited = new boolean[n][m];
			if (grid[n - 1][m - 1] != '#') {
				q.add(new Integer[] {n - 1, m - 1});
				visited[n - 1][m - 1] = true;
			}
			int c = 0;
			boolean flag = true;
			while (!q.isEmpty() && flag) {
				Integer[] arr = q.poll();
				int x1 = arr[0];
				int y1 = arr[1];
				if (grid[x1][y1] == 'G')
					c++;
				else if (grid[x1][y1] == 'B'){
					flag = false;
					break;
				}
				for (int i = 0; i < 4; i++) {
					int x = dx[i] + x1;
					int y = dy[i] + y1;
					if (x < n && x >= 0 && y < m && y >= 0 && grid[x][y] != '#' && !visited[x][y]) {
						visited[x][y] = true;
						q.add(new Integer[] {x,y});
					}

				}
			}

			if (!flag)
				System.out.println("No");
			else if (whites != c)
				System.out.println("No");
			else
				System.out.println("Yes");

		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class D {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(bf.readLine());
        for (int i = 0; i < t; i++) {
            StringTokenizer st = new StringTokenizer(bf.readLine());
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            char[][] maze = new char[n][m];
            int numBad = 0;
            int numGood = 0;
            for (int j = 0; j < n; j++) {
                String line = bf.readLine();
                for (int k = 0; k < m; k++) {
                    maze[j][k] = line.charAt(k);
                    if (maze[j][k] == 'G') {
                        numGood++;
                    } else if (maze[j][k] == 'B') {
                        numBad++;
                    }
                }
            }
            if (numGood == 0) {
                // can just block off exit, it's always empty
                out.println("Yes");
                continue;
            }
            if (numBad == 0) {
                boolean[][] seen = new boolean[n][m];
                if (numGood == dfs(maze, n - 1, m - 1, seen)) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
                continue;
            }
            boolean poss = true; // if we have to wall a G we're screwed
            // just wall off all the bad, and then dfs to see if we can
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < m; k++) {
                    if (maze[j][k] == 'B') {
                        if (j > 0) {
                            if (maze[j-1][k] == 'G') {
                                poss = false;
                            }
                            maze[j-1][k] = '#';
                        }
                        if (k > 0) {
                            if (maze[j][k-1] == 'G') {
                                poss = false;
                            }
                            maze[j][k-1] = '#';
                        }
                        if (j < n - 1) {
                            if (maze[j+1][k] == 'G') {
                                poss = false;
                            }
                            maze[j+1][k] = '#';
                        }
                        if (k < m - 1) {
                            if (maze[j][k+1] == 'G') {
                                poss = false;
                            }
                            maze[j][k+1] = '#';
                        }
                    }
                }
            }
            if (!poss) {
                out.println("No");
                continue;
            }
            boolean[][] seen = new boolean[n][m];
            if (numGood == dfs(maze, n - 1, m - 1, seen)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
        out.close();
        System.exit(0);
	}

    // dfs from loc returns # of good encountered
    public static int dfs(char[][] maze, int i, int j, boolean[][] seen) {
        if (seen[i][j]) return 0;
        if (maze[i][j] == '#') return 0;
        int ret = 0;
        seen[i][j] = true;
        if (maze[i][j] == 'G') ret++;
        if (i > 0) {
            if (!seen[i-1][j] && maze[i-1][j] != '#') {
                ret += dfs(maze, i-1, j, seen);
            }
        }
        if (j > 0) {
            if (!seen[i][j-1] && maze[i][j-1] != '#') {
                ret += dfs(maze, i, j-1, seen);
            }
        }
        if (i < maze.length - 1) {
            if (!seen[i+1][j] && maze[i+1][j] != '#') {
                ret += dfs(maze, i+1, j, seen);
            }
        }
        if (j < maze[i].length - 1) {
            if (!seen[i][j+1] && maze[i][j+1] != '#') {
                ret += dfs(maze, i, j+1, seen);
            }
        }
        return ret;
    }

    public static int max(int a, int b) {
        return a > b ? a : b;
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;

public class D {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(bf.readLine());
        for (int i = 0; i < t; i++) {
            StringTokenizer st = new StringTokenizer(bf.readLine());
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
            char[][] maze = new char[n][m];
            int numBad = 0;
            int numGood = 0;
            for (int j = 0; j < n; j++) {
                String line = bf.readLine();
                for (int k = 0; k < m; k++) {
                    maze[j][k] = line.charAt(k);
                    if (maze[j][k] == 'G') {
                        numGood++;
                    } else if (maze[j][k] == 'B') {
                        numBad++;
                    }
                }
            }
            if (numGood == 0) {
                // can just block off exit, it's always empty
                out.println("Yes");
                continue;
            }
            if (numBad == 0) {
                boolean[][] seen = new boolean[n][m];
                if (numGood == dfs(maze, n - 1, m - 1, seen)) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
                continue;
            }
            boolean poss = true; // if we have to wall a G we're screwed
            // just wall off all the bad, and then dfs to see if we can
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < m; k++) {
                    if (maze[j][k] == 'B') {
                        if (j > 0) {
                            if (maze[j-1][k] == 'G') {
                                poss = false;
                            }
                            if (maze[j-1][k] != 'B') {
                                maze[j-1][k] = '#';
                            }
                        }
                        if (k > 0) {
                            if (maze[j][k-1] == 'G') {
                                poss = false;
                            }
                            if (maze[j][k-1] != 'B') {
                                maze[j][k-1] = '#';
                            }
                        }
                        if (j < n - 1) {
                            if (maze[j+1][k] == 'G') {
                                poss = false;
                            }
                            if (maze[j+1][k] != 'B') {
                                maze[j+1][k] = '#';
                            }
                        }
                        if (k < m - 1) {
                            if (maze[j][k+1] == 'G') {
                                poss = false;
                            }
                            if (maze[j][k+1] != 'B') {
                                maze[j][k+1] = '#';
                            }
                        }
                    }
                }
            }

            if (!poss) {
                out.println("No");
                continue;
            }
            boolean[][] seen = new boolean[n][m];
            if (numGood == dfs(maze, n - 1, m - 1, seen)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
        out.close();
        System.exit(0);
	}

    // dfs from loc returns # of good encountered
    public static int dfs(char[][] maze, int i, int j, boolean[][] seen) {
        if (seen[i][j]) return 0;
        if (maze[i][j] == '#') return 0;
        int ret = 0;
        seen[i][j] = true;
        if (maze[i][j] == 'G') ret++;
        if (i > 0) {
            if (!seen[i-1][j] && maze[i-1][j] != '#') {
                ret += dfs(maze, i-1, j, seen);
            }
        }
        if (j > 0) {
            if (!seen[i][j-1] && maze[i][j-1] != '#') {
                ret += dfs(maze, i, j-1, seen);
            }
        }
        if (i < maze.length - 1) {
            if (!seen[i+1][j] && maze[i+1][j] != '#') {
                ret += dfs(maze, i+1, j, seen);
            }
        }
        if (j < maze[i].length - 1) {
            if (!seen[i][j+1] && maze[i][j+1] != '#') {
                ret += dfs(maze, i, j+1, seen);
            }
        }
        return ret;
    }

    public static int max(int a, int b) {
        return a > b ? a : b;
    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static boolean check(int i,int j,int arr[][])
	{
		int n=arr.length,m=arr[0].length;
		if(i>=n)
			return false;
		if(i<0)
			return false;
		if(j>=m)
			return false;
		if(j<0)
			return false;
		if(arr[i][j]==1)
			return false;
		if(arr[i][j]==-1)
			return false;
		return true;
	}
	public static void main(String[] args)   {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-->0)
		{
			int n=scan.nextInt();
			int m=scan.nextInt();
			int arr[][]=new int[n][m];
			ArrayList<Node> bad = new ArrayList<Node>();
			int count=0;
			for(int i=0;i<n;i++)
			{
				String temp = scan.next();
				for(int j=0;j<m;j++)
				{
					if(temp.charAt(j)=='.')
						arr[i][j]=0;
					else if(temp.charAt(j)=='#')
						arr[i][j]=1;
					else if(temp.charAt(j)=='G')
					{
						arr[i][j]=2;
						count++;
					}
					else {
						arr[i][j]=3;
						bad.add(new Node(i, j));
					}
				}
			}
			for(Node x:bad)
			{
				int i = x.i;
				int j = x.j;
				if (((i+1)<n)&&(arr[i+1][j]==0))
					arr[i+1][j]=1;
				if(((i-1)>=0)&&(arr[i-1][j]==0))
					arr[i-1][j]=1;
				if(((j+1)<m)&&(arr[i][j+1]==0))
					arr[i][j+1]=1;
				if(((j-1)>=0)&&(arr[i][j-1]==0))
					arr[i][j+1]=1;
			}
			Stack<Node> s = new Stack<Node>();
			if(arr[n-1][m-1]!=1)
				s.push(new Node(n-1, m-1));
			boolean poss=true;
			while(!s.isEmpty())
			{
				Node x = s.pop();
				int i=x.i,j=x.j;
				if(arr[i][j]==-1)
					continue;
				if(arr[i][j]==3)
					poss=false;
				if(arr[i][j]==2)
					count--;
				arr[i][j]=-1;
				if(check(i+1, j, arr))
					s.push(new Node(i+1, j));
				if(check(i-1, j, arr))
					s.push(new Node(i-1, j));
				if(check(i, j+1, arr))
					s.push(new Node(i, j+1));
				if(check(i, j-1, arr))
					s.push(new Node(i, j-1));
			}
			if((poss)&&(count==0))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}
class Node{
	public int i,j;
	public Node(int i,int j) {
		this.i=i;
		this.j=j;
	}
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main{
	public static boolean check(int i,int j,int arr[][])
	{
		int n=arr.length,m=arr[0].length;
		if(i>=n)
			return false;
		if(i<0)
			return false;
		if(j>=m)
			return false;
		if(j<0)
			return false;
		if(arr[i][j]==1)
			return false;
		if(arr[i][j]==-1)
			return false;
		return true;
	}
	public static void main(String[] args)   {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-->0)
		{
			int n=scan.nextInt();
			int m=scan.nextInt();
			int arr[][]=new int[n][m];
			ArrayList<Node> bad = new ArrayList<Node>();
			int count=0;
			for(int i=0;i<n;i++)
			{
				String temp = scan.next();
				for(int j=0;j<m;j++)
				{
					if(temp.charAt(j)=='.')
						arr[i][j]=0;
					else if(temp.charAt(j)=='#')
						arr[i][j]=1;
					else if(temp.charAt(j)=='G')
					{
						arr[i][j]=2;
						count++;
					}
					else {
						arr[i][j]=3;
						bad.add(new Node(i, j));
					}
				}
			}
			for(Node x:bad)
			{
				int i = x.i;
				int j = x.j;
				if (((i+1)<n)&&(arr[i+1][j]==0))
					arr[i+1][j]=1;
				if(((i-1)>=0)&&(arr[i-1][j]==0))
					arr[i-1][j]=1;
				if(((j+1)<m)&&(arr[i][j+1]==0))
					arr[i][j+1]=1;
				if(((j-1)>=0)&&(arr[i][j-1]==0))
					arr[i][j-1]=1;
			}
			Stack<Node> s = new Stack<Node>();
			if(arr[n-1][m-1]!=1)
				s.push(new Node(n-1, m-1));
			boolean poss=true;
			while(!s.isEmpty())
			{
				Node x = s.pop();
				int i=x.i,j=x.j;
				if(arr[i][j]==-1)
					continue;
				if(arr[i][j]==3)
					poss=false;
				if(arr[i][j]==2)
					count--;
				arr[i][j]=-1;
				if(check(i+1, j, arr))
					s.push(new Node(i+1, j));
				if(check(i-1, j, arr))
					s.push(new Node(i-1, j));
				if(check(i, j+1, arr))
					s.push(new Node(i, j+1));
				if(check(i, j-1, arr))
					s.push(new Node(i, j-1));
			}
			if((poss)&&(count==0))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}
class Node{
	public int i,j;
	public Node(int i,int j) {
		this.i=i;
		this.j=j;
	}
}


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();

    }

    static long INF = (long)1e18;
    static int maxn = (int)2e6+5;
    static int mod  = 1000*1000*1000+7;
    static int n,m,q,k,t;

    static char[][] c;
    static boolean[][] visb, visg;

    void solve() throws IOException{
        t = in.nextInt();

        while (t --> 0) {
            n = in.nextInt();
            m = in.nextInt();

            ArrayDeque<Node> bq = new ArrayDeque<>();
            ArrayDeque<Node> gq = new ArrayDeque<>();

            visb = new boolean[n][m];
            visg = new boolean[n][m];
            String s;
            c = new char[n][m];

            int cnt = 0;
            for (int i = 0; i < n; i++) {
                s = in.next();
                for (int j = 0; j < m; j++) {
                    c[i][j] = s.charAt(j);
                    if (c[i][j] == 'B') bq.add(new Node(i, j));
                    else if (c[i][j] == 'G') {
                        gq.add(new Node(i, j));
                        cnt++;
                    }
                }
            }

            int xx = 0, yy = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == 'B') {
                        for (int z = 0; z < 4; z++) {
                            xx = i + dx[z];
                            yy = j + dy[z];
                            if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                                if (c[xx][yy] == '.') c[xx][yy] = '#';
                            }
                        }
                    }
                }
            }

            bfs(bq, 0);
            bfs(gq, 1);
            if ((!visg[n-1][m-1] && cnt != 0) || visb[n-1][m-1]) out.println("No");
            else out.println("Yes");
        }
    }

    //<>

    static int[] dx = {-1,0,0,1};
    static int[] dy = {0, 1, -1, 0};

    static void bfs(ArrayDeque<Node> q, int tt) {
        Node elm;
        while (q.size() != 0) {
            elm = q.remove();
            if (tt == 0) visb[elm.x][elm.y] = true;
            else visg[elm.x][elm.y] = true;

            int xx, yy;
            for (int i = 0; i < 4; i++) {
                xx = elm.x + dx[i];
                yy = elm.y + dy[i];
                if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                    if (tt == 0 && !visb[xx][yy] && c[xx][yy] != '#') {
                        visb[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    } else if (tt == 1 && !visg[xx][yy] && c[xx][yy] != '#') {
                        visg[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    }
                }
            }
        }
    }

    static class Node {
        int x, y;
        Node (int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    static class Reader {

    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public Reader() {
        this(System.in);
    }

    public Reader(InputStream is) {
        mIs = is;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();

    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    }
}


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();

    }

    static long INF = (long)1e18;
    static int maxn = (int)2e6+5;
    static int mod  = 1000*1000*1000+7;
    static int n,m,q,k,t;

    static char[][] c;
    static boolean[][] visb, visg;

    void solve() throws IOException{
        t = in.nextInt();

        while (t --> 0) {
            n = in.nextInt();
            m = in.nextInt();

            ArrayDeque<Node> bq = new ArrayDeque<>();
            ArrayDeque<Node> gq = new ArrayDeque<>();

            visb = new boolean[n][m];
            visg = new boolean[n][m];
            String s;
            c = new char[n][m];

            ArrayList<Node> pep =new ArrayList<Node>();

            int cnt = 0;
            for (int i = 0; i < n; i++) {
                s = in.next();
                for (int j = 0; j < m; j++) {
                    c[i][j] = s.charAt(j);
                    if (c[i][j] == 'B') bq.add(new Node(i, j));
                    else if (c[i][j] == 'G' && cnt == 0) {
                        gq.add(new Node(i, j));
                        cnt++;
                    }
                    if (c[i][j] == 'G') {
                        pep.add(new Node (i, j));
                    }
                }
            }

            int xx = 0, yy = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == 'B') {
                        for (int z = 0; z < 4; z++) {
                            xx = i + dx[z];
                            yy = j + dy[z];
                            if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                                if (c[xx][yy] == '.') c[xx][yy] = '#';
                            }
                        }
                    }
                }
            }

            bfs(bq, 0);
            bfs(gq, 1);

            boolean flag=  true;
            for (Node e: pep) {
                if (!visg[e.x][e.y]) flag = false;
            }
            if ((!visg[n-1][m-1] && cnt != 0) || visb[n-1][m-1] || !flag) out.println("No");
            else out.println("Yes");
        }
    }

    //<>

    static int[] dx = {-1,0,0,1};
    static int[] dy = {0, 1, -1, 0};

    static void bfs(ArrayDeque<Node> q, int tt) {
        Node elm;
        while (q.size() != 0) {
            elm = q.remove();
            if (tt == 0) visb[elm.x][elm.y] = true;
            else visg[elm.x][elm.y] = true;

            int xx, yy;
            for (int i = 0; i < 4; i++) {
                xx = elm.x + dx[i];
                yy = elm.y + dy[i];
                if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                    if (tt == 0 && !visb[xx][yy] && c[xx][yy] != '#') {
                        visb[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    } else if (tt == 1 && !visg[xx][yy] && c[xx][yy] != '#') {
                        visg[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    }
                }
            }
        }
    }

    static class Node {
        int x, y;
        Node (int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    static class Reader {

    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public Reader() {
        this(System.in);
    }

    public Reader(InputStream is) {
        mIs = is;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();

    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    }
}


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();

    }

    static long INF = (long)1e18;
    static int maxn = (int)2e6+5;
    static int mod  = 1000*1000*1000+7;
    static int n,m,q,k,t;

    static char[][] c;
    static boolean[][] visb, visg;

    void solve() throws IOException{
        t = in.nextInt();

        while (t --> 0) {
            n = in.nextInt();
            m = in.nextInt();

            ArrayDeque<Node> bq = new ArrayDeque<>();
            ArrayDeque<Node> gq = new ArrayDeque<>();

            visb = new boolean[n][m];
            visg = new boolean[n][m];
            String s;
            c = new char[n][m];

            int cnt = 0;
            for (int i = 0; i < n; i++) {
                s = in.next();
                for (int j = 0; j < m; j++) {
                    c[i][j] = s.charAt(j);
                    if (c[i][j] == 'B') bq.add(new Node(i, j));
                    else if (c[i][j] == 'G') {
                        gq.add(new Node(i, j));
                        cnt++;
                    }
                }
            }

            int xx = 0, yy = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (c[i][j] == 'B') {
                        for (int z = 0; z < 4; z++) {
                            xx = i + dx[z];
                            yy = j + dy[z];
                            if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                                if (c[xx][yy] == '.') c[xx][yy] = '#';
                            }
                        }
                    }
                }
            }

            bfs(bq, 0);
            bfs(gq, 1);
            if ((!visg[n-1][m-1] && cnt != 0) || visb[n-1][m-1]) out.println("No");
            else out.println("Yes");
        }
    }

    //<>

    static int[] dx = {-1,0,0,1};
    static int[] dy = {0, 1, -1, 0};

    static void bfs(ArrayDeque<Node> q, int tt) {
        Node elm;
        while (q.size() != 0) {
            elm = q.remove();
            if (tt == 0) visb[elm.x][elm.y] = true;
            else visg[elm.x][elm.y] = true;

            int xx, yy;
            for (int i = 0; i < 4; i++) {
                xx = elm.x + dx[i];
                yy = elm.y + dy[i];
                if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
                    if (tt == 0 && !visb[xx][yy] && c[xx][yy] == '.') {
                        visb[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    } else if (tt == 1 && !visg[xx][yy] && c[xx][yy] == '.') {
                        visg[xx][yy] = true;
                        q.add(new Node(xx, yy));
                    }
                }
            }
        }
    }

    static class Node {
        int x, y;
        Node (int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    static class Reader {

    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public Reader() {
        this(System.in);
    }

    public Reader(InputStream is) {
        mIs = is;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();

    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    }
}