//   package com.company;
import javax.swing.plaf.IconUIResource;
import java.util.*;
import java.io.*;
import java.lang.*;
/*
 ** @author jigar_nainuji
 */
public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
        int t = in.nextInt();
//        int t=1;
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {

        static int mod = 1000000007;
        static void solve(int i,int j,int n,int m,char[][] ch,boolean[][] f)
        {
            if(ch[i][j]=='#')
                return;
            f[i][j]=true;
            if(i-1>=0 && !f[i-1][j])
            {
                solve(i-1,j,n,m,ch,f);
            }
            if(i+1<n && !f[i+1][j] )
            {
                solve(i+1,j,n,m,ch,f);
            }
            if(j-1>=0 && !f[i][j-1])
            {
                solve(i,j-1,n,m,ch,f);
            }
            if(j+1<m && !f[i][j+1])
            {
                solve(i,j+1,n,m,ch,f);
            }
            if(i-1>=0 && j-1>=0 && !f[i-1][j-1])
            {
                solve(i-1,j-1,n,m,ch,f);
            }
            if(i+1<n && j-1>=0 && !f[i+1][j-1])
            {
                solve(i+1,j-1,n,m,ch,f);
            }
            if(i-1>=0 && j+1<m && !f[i-1][j+1])
            {
                solve(i-1,j+1,n,m,ch,f);
            }
            if(i+1<n && j+1<m && !f[i+1][j+1])
            {
                solve(i+1,j+1,n,m,ch,f);
            }

        }
        void solve(InputReader in, PrintWriter out, int testNumber) {
            int n = in.nextInt();
            int m = in.nextInt();
            char ch[][] = new char[n][m];
            for(int i=0;i<n;i++)
            {
                ch[i]=in.next().toCharArray();
            }
            int good=0,bad=0,dot=0,wall=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                        good++;
                    else if(ch[i][j]=='B')
                        bad++;
                    else if(ch[i][j]=='.')
                        dot++;
                    else
                        wall++;
                }
            }
            if(good==0)
            {
                System.out.println("Yes");
                return;
            }
            boolean flag=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                    {
                        if(i-1>=0 && ch[i-1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && ch[i+1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j-1>=0 && ch[i][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j+1<m && ch[i][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                    }
                }
                if(!flag)
                    break;
            }
            if(!flag)
            {
                System.out.println("No");
                return;
            }
            boolean ff=false;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='B')
                    {
                        if(i-1>=0 && ch[i-1][j]!='B')
                        {
                            if(ch[i-1][j]=='.')
                                ff=true;
                            ch[i-1][j]='#';
                        }
                        if(i+1<n && ch[i+1][j]!='B')
                        {
                            if(ch[i+1][j]=='.')
                                ff=true;
                            ch[i+1][j]='#';
                        }
                        if(j-1>=0 && ch[i][j-1]!='B')
                        {
                            if(ch[i][j-1]=='.')
                                ff=true;
                            ch[i][j-1]='#';
                        }
                        if(j+1<m && ch[i][j+1]!='B')
                        {
                            if(ch[i][j+1]=='.')
                                ff=true;
                            ch[i][j+1]='#';
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]!='B')
                        {
                            if(ch[i-1][j-1]=='.')
                                ff=true;
                            ch[i-1][j-1]='#';

                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]!='B')
                        {
                            if(ch[i+1][j-1]=='.')
                                ff=true;
                            ch[i+1][j-1]='#';
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]!='B')
                        {
                            if(ch[i-1][j+1]=='.')
                                ff=true;
                            ch[i-1][j+1]='#';
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]!='B')
                        {
                            if(ch[i+1][j+1]=='.')
                                ff=true;
                            ch[i+1][j+1]='#';
                        }
                    }
                }
            }
            boolean f[][] = new boolean[n][m];
            solve(n-1,m-1,n,m,ch,f);
            boolean ans=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G' && !f[i][j])
                    {
                        ans=false;
                        break;
                    }
                }
                if(!ans)
                    break;
            }
            if(ans && ff)
                System.out.println("Yes");
            else
                System.out.println("No");

        }
    }
    static class Maths{
        static long gcd(long a, long b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public  static long lcm(long a, long b)
        {
            return (a*b)/gcd(a, b);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }
    static class pair{
        int a;
        int b;
        pair(int a,int b)
        {
            this.a=a;
            this.b=b;
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


//   package com.company;
import javax.swing.plaf.IconUIResource;
import java.util.*;
import java.io.*;
import java.lang.*;
/*
 ** @author jigar_nainuji
 */
public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
        int t = in.nextInt();
//        int t=1;
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {

        static int mod = 1000000007;
        static void solve(int i,int j,int n,int m,char[][] ch,boolean[][] f)
        {
            if(ch[i][j]=='#')
                return;
            f[i][j]=true;
            if(i-1>=0 && !f[i-1][j])
            {
                solve(i-1,j,n,m,ch,f);
            }
            if(i+1<n && !f[i+1][j] )
            {
                solve(i+1,j,n,m,ch,f);
            }
            if(j-1>=0 && !f[i][j-1])
            {
                solve(i,j-1,n,m,ch,f);
            }
            if(j+1<m && !f[i][j+1])
            {
                solve(i,j+1,n,m,ch,f);
            }

        }
        void solve(InputReader in, PrintWriter out, int testNumber) {
            int n = in.nextInt();
            int m = in.nextInt();
            char ch[][] = new char[n][m];
            for(int i=0;i<n;i++)
            {
                ch[i]=in.next().toCharArray();
            }
            int good=0,bad=0,dot=0,wall=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                        good++;
                    else if(ch[i][j]=='B')
                        bad++;
                }
            }
            if(good==0)
            {
                System.out.println("Yes");
                return;
            }
            boolean flag=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                    {
                        if(i-1>=0 && ch[i-1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && ch[i+1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j-1>=0 && ch[i][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j+1<m && ch[i][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }

                    }
                }
                if(!flag)
                    break;
            }
            if(!flag)
            {
                System.out.println("No");
                return;
            }
            boolean ff=false;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='B')
                    {
                        if(i-1>=0 && ch[i-1][j]!='B')
                        {
                            if(ch[i-1][j]=='.')
                                ff=true;
                            ch[i-1][j]='#';
                        }
                        if(i+1<n && ch[i+1][j]!='B')
                        {
                            if(ch[i+1][j]=='.')
                                ff=true;
                            ch[i+1][j]='#';
                        }
                        if(j-1>=0 && ch[i][j-1]!='B')
                        {
                            if(ch[i][j-1]=='.')
                                ff=true;
                            ch[i][j-1]='#';
                        }
                        if(j+1<m && ch[i][j+1]!='B')
                        {
                            if(ch[i][j+1]=='.')
                                ff=true;
                            ch[i][j+1]='#';
                        }

                    }
                }
            }
            boolean f[][] = new boolean[n][m];
            solve(n-1,m-1,n,m,ch,f);
            boolean ans=true;

            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G' && !f[i][j])
                    {
                        ans=false;
                        break;
                    }
                }
                if(!ans)
                    break;
            }
            if(ans )
                System.out.println("Yes");
            else
                System.out.println("No");

        }
    }
    static class Maths{
        static long gcd(long a, long b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public  static long lcm(long a, long b)
        {
            return (a*b)/gcd(a, b);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }
    static class pair{
        int a;
        int b;
        pair(int a,int b)
        {
            this.a=a;
            this.b=b;
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


//   package com.company;
import javax.swing.plaf.IconUIResource;
import java.util.*;
import java.io.*;
import java.lang.*;
/*
 ** @author jigar_nainuji
 */
public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
        int t = in.nextInt();
//        int t=1;
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {

        static int mod = 1000000007;
        static void solve(int i,int j,int n,int m,char[][] ch,boolean[][] f)
        {
            if(ch[i][j]=='#')
                return;
            f[i][j]=true;
            if(i-1>=0 && !f[i-1][j])
            {
                solve(i-1,j,n,m,ch,f);
            }
            if(i+1<n && !f[i+1][j] )
            {
                solve(i+1,j,n,m,ch,f);
            }
            if(j-1>=0 && !f[i][j-1])
            {
                solve(i,j-1,n,m,ch,f);
            }
            if(j+1<m && !f[i][j+1])
            {
                solve(i,j+1,n,m,ch,f);
            }
            if(i-1>=0 && j-1>=0 && !f[i-1][j-1])
            {
                solve(i-1,j-1,n,m,ch,f);
            }
            if(i+1<n && j-1>=0 && !f[i+1][j-1])
            {
                solve(i+1,j-1,n,m,ch,f);
            }
            if(i-1>=0 && j+1<m && !f[i-1][j+1])
            {
                solve(i-1,j+1,n,m,ch,f);
            }
            if(i+1<n && j+1<m && !f[i+1][j+1])
            {
                solve(i+1,j+1,n,m,ch,f);
            }

        }
        void solve(InputReader in, PrintWriter out, int testNumber) {
            int n = in.nextInt();
            int m = in.nextInt();
            char ch[][] = new char[n][m];
            for(int i=0;i<n;i++)
            {
                ch[i]=in.next().toCharArray();
            }
            int good=0,bad=0,dot=0,wall=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                        good++;
                    else if(ch[i][j]=='B')
                        bad++;
                    else if(ch[i][j]=='.')
                        dot++;
                    else
                        wall++;
                }
            }
            if(good==0)
            {
                System.out.println("Yes");
                return;
            }
            boolean flag=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                    {
                        if(i-1>=0 && ch[i-1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && ch[i+1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j-1>=0 && ch[i][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j+1<m && ch[i][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                    }
                }
                if(!flag)
                    break;
            }
            if(!flag)
            {
                System.out.println("No");
                return;
            }
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='B')
                    {
                        if(i-1>=0 && ch[i-1][j]!='B')
                        {
                            ch[i-1][j]='#';
                        }
                        if(i+1<n && ch[i+1][j]!='B')
                        {
                            ch[i+1][j]='#';
                        }
                        if(j-1>=0 && ch[i][j-1]!='B')
                        {
                            ch[i][j-1]='#';
                        }
                        if(j+1<m && ch[i][j+1]!='B')
                        {
                            ch[i][j+1]='#';
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]!='B')
                        {
                            ch[i-1][j-1]='#';
                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]!='B')
                        {
                            ch[i+1][j-1]='#';
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]!='B')
                        {
                            ch[i-1][j+1]='#';
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]!='B')
                        {
                            ch[i+1][j+1]='#';
                        }
                    }
                }
            }
            boolean f[][] = new boolean[n][m];
            solve(n-1,m-1,n,m,ch,f);
            boolean ans=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G' && !f[i][j])
                    {
                        ans=false;
                        break;
                    }
                }
                if(!ans)
                    break;
            }
            if(ans)
                System.out.println("Yes");
            else
                System.out.println("No");

        }
    }
    static class Maths{
        static long gcd(long a, long b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public  static long lcm(long a, long b)
        {
            return (a*b)/gcd(a, b);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }
    static class pair{
        int a;
        int b;
        pair(int a,int b)
        {
            this.a=a;
            this.b=b;
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


//   package com.company;
import javax.swing.plaf.IconUIResource;
import java.util.*;
import java.io.*;
import java.lang.*;
/*
 ** @author jigar_nainuji
 */
public class Main{

    public static void main(String args[]){
        PrintWriter out=new PrintWriter(System.out);
        InputReader in=new InputReader(System.in);
        TASK solver = new TASK();
        int t = in.nextInt();
//        int t=1;
        for(int i=0;i<t;i++)
        {
            solver.solve(in,out,i);
        }
        out.close();
    }
    static class TASK {

        static int mod = 1000000007;
        static void solve(int i,int j,int n,int m,char[][] ch,boolean[][] f)
        {
            if(ch[i][j]=='#')
                return;
            f[i][j]=true;
            if(i-1>=0 && !f[i-1][j])
            {
                solve(i-1,j,n,m,ch,f);
            }
            if(i+1<n && !f[i+1][j] )
            {
                solve(i+1,j,n,m,ch,f);
            }
            if(j-1>=0 && !f[i][j-1])
            {
                solve(i,j-1,n,m,ch,f);
            }
            if(j+1<m && !f[i][j+1])
            {
                solve(i,j+1,n,m,ch,f);
            }
            if(i-1>=0 && j-1>=0 && !f[i-1][j-1])
            {
                solve(i-1,j-1,n,m,ch,f);
            }
            if(i+1<n && j-1>=0 && !f[i+1][j-1])
            {
                solve(i+1,j-1,n,m,ch,f);
            }
            if(i-1>=0 && j+1<m && !f[i-1][j+1])
            {
                solve(i-1,j+1,n,m,ch,f);
            }
            if(i+1<n && j+1<m && !f[i+1][j+1])
            {
                solve(i+1,j+1,n,m,ch,f);
            }

        }
        void solve(InputReader in, PrintWriter out, int testNumber) {
            int n = in.nextInt();
            int m = in.nextInt();
            char ch[][] = new char[n][m];
            for(int i=0;i<n;i++)
            {
                ch[i]=in.next().toCharArray();
            }
            int good=0,bad=0,dot=0,wall=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                        good++;
                    else if(ch[i][j]=='B')
                        bad++;
                    else if(ch[i][j]=='.')
                        dot++;
                    else
                        wall++;
                }
            }
            if(good==0 || bad==0)
            {
                System.out.println("Yes");
                return;
            }
            boolean flag=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G')
                    {
                        if(i-1>=0 && ch[i-1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && ch[i+1][j]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j-1>=0 && ch[i][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(j+1<m && ch[i][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]=='B')
                        {
                            flag=false;
                            break;
                        }
                    }
                }
                if(!flag)
                    break;
            }
            if(!flag)
            {
                System.out.println("No");
                return;
            }
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='B')
                    {
                        if(i-1>=0 && ch[i-1][j]!='B')
                        {
                            ch[i-1][j]='#';
                        }
                        if(i+1<n && ch[i+1][j]!='B')
                        {
                            ch[i+1][j]='#';
                        }
                        if(j-1>=0 && ch[i][j-1]!='B')
                        {
                            ch[i][j-1]='#';
                        }
                        if(j+1<m && ch[i][j+1]!='B')
                        {
                            ch[i][j+1]='#';
                        }
                        if(i-1>=0 && j-1>=0 && ch[i-1][j-1]!='B')
                        {
                            ch[i-1][j-1]='#';
                        }
                        if(i+1<n && j-1>=0 && ch[i+1][j-1]!='B')
                        {
                            ch[i+1][j-1]='#';
                        }
                        if(i-1>=0 && j+1<m && ch[i-1][j+1]!='B')
                        {
                            ch[i-1][j+1]='#';
                        }
                        if(i+1<n && j+1<m && ch[i+1][j+1]!='B')
                        {
                            ch[i+1][j+1]='#';
                        }
                    }
                }
            }
            boolean f[][] = new boolean[n][m];
            solve(n-1,m-1,n,m,ch,f);
            boolean ans=true;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='G' && !f[i][j])
                    {
                        ans=false;
                        break;
                    }
                }
                if(!ans)
                    break;
            }
            if(ans)
                System.out.println("Yes");
            else
                System.out.println("No");

        }
    }
    static class Maths{
        static long gcd(long a, long b) {
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }

        public  static long lcm(long a, long b)
        {
            return (a*b)/gcd(a, b);
        }

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }
    static class pair{
        int a;
        int b;
        pair(int a,int b)
        {
            this.a=a;
            this.b=b;
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        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 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 double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}


import java.io.*;
import java.util.*;
public class sol{
    InputReader in;
    final long mod=1000000007;
    StringBuilder sb;
    public static void main(String[] args) throws java.lang.Exception{
        new sol().run();
    }
    void run() throws Exception {
        in=new InputReader(System.in);
        sb = new  StringBuilder();
        int t=i();
        while(t-->0)
            solve();
        System.out.print(sb);
    }
    char c[][];
    int n,m;
    boolean vis[][];
    boolean isValid(int i,int j) {
        if(i<n && i>=0 && j<m && j>=0)
            return true;
        return false;
    }
    void dfs(int i,int j) {
        if(isValid(i+1,j) && !vis[i+1][j] && c[i+1][j]!='#') {
            vis[i+1][j]=true;
            dfs(i+1,j);
        }
        if(isValid(i,j+1) && !vis[i][j+1] && c[i][j+1]!='#') {
            vis[i][j+1]=true;
            dfs(i,j+1);
        }
        if(isValid(i-1,j) && !vis[i-1][j] && c[i-1][j]!='#') {
            vis[i-1][j]=true;
            dfs(i-1,j);
        }
        if(isValid(i,j-1) && !vis[i][j-1] && c[i][j-1]!='#') {
            vis[i][j-1]=true;
            dfs(i,j-1);
        }
    }
    void solve() {
        n=i();
        m=i();
        int i,j;
        c=new char[n][m];
        vis=new boolean[n][m];
        for(i=0;i<n;i++)
            c[i]=s().toCharArray();
        for(i=0;i<n;i++) {
            for(j=0;j<m;j++) {
                if(c[i][j]=='B') {
                    if(isValid(i+1,j) && c[i+1][j]=='.')
                        c[i+1][j]='#';
                    if(isValid(i,j+1) && c[i][j+1]=='.')
                        c[i][j+1]='#';
                    if(isValid(i-1,j) && c[i-1][j]=='.')
                        c[i-1][j]='#';
                    if(isValid(i,j-1) && c[i][j-1]=='.')
                        c[i][j-1]='#';
                }
            }
        }
        if(c[n-1][m-1]=='.')
            dfs(n-1,m-1);
        boolean flag=true;
        for(i=0;i<n;i++) {
            for(j=0;j<m;j++) {
                if((c[i][j]=='G' && !vis[i][j]) || (c[i][j]=='B' && vis[i][j])) {
                    flag=false;
                    break;
                }
            }
        }
        if(flag==false)
            sb.append("No\n");
        else
            sb.append("Yes\n");
    }
    long power(long a, long b){
        if(b == 0)
            return 1L;
        long val = power(a, b / 2);
        if(b % 2 == 0)
            return val * val%mod;
        else
            return val * val%mod * a%mod;
    }
    int gcd(int a, int b) {
        return (b==0)?a:gcd(b,a%b);
    }
    String s(){return in.next();}
    int i(){return in.nextInt();}
    long l(){return in.nextLong();}
    class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }
        public void skip(int x) {
            while (x-->0)
                read();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public String nextString() {
            return next();
        }
        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }
        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}


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

public class D {
    final static int dx[] = {0, 0, 1, -1};
    final static int dy[] = {1, -1, 0, 0};
    public static ArrayList<List<Character>> maze = new ArrayList<List<Character>>();
    public static ArrayList<List<Integer>> vis = new ArrayList<List<Integer>>();
    public static Deque<List<Integer>> Bstack = new LinkedList<List<Integer>>();
    public static Deque<List<Integer>> Gstack = new LinkedList<List<Integer>>();
    public static Deque<List<Integer>> stack = new LinkedList<List<Integer>>();
    public static int n, m;

    public static void printMaze() {
        for (int i=0; i<n; i++) {
            System.out.println();
            for (int j=0; j<m; j++)
                System.out.print(maze.get(i).get(j) + " ");
        }
    }

    public static Boolean isValid(int i, int j) {
        if (i>=0 && i<n && j>=0 && j<m)
            return true;
        else
            return false;
    }

    public static Boolean findBadNodes() {
        Boolean valid = true;
        outerloop:
        while (!Bstack.isEmpty()) {
            int p = Bstack.peek().get(0);
            int q = Bstack.peek().get(1);
            Bstack.pop();
            maze.get(p).set(q, '#');
            for (int i=0; i<4; i++) {
                int pi = p+dx[i];
                int qi = q+dy[i];
                if (isValid(pi, qi)) {
                    char tmp = maze.get(pi).get(qi);
                    if (tmp == 'G' || (pi == n-1 && qi == m-1)) {
                        valid = false;
                        break outerloop;
                    }
                    if (tmp == '.')
                        maze.get(pi).set(qi, '#');
                }
            }
        }
        return valid;
    }

    public static void dfs(int p, int q) {
        stack.push(Arrays.asList(p, q));
        vis.get(p).set(q, 1);
        if (p == n-1 && q == m-1)
            return;
        int c = 0;
        for (int i=0; i<4; i++) {
            int pi = p + dx[i];
            int qi = q + dy[i];
            if (isValid(pi, qi) && vis.get(pi).get(qi) < 1 && maze.get(pi).get(qi) != '#') {
                c++;
                dfs(pi, qi);
                if (vis.get(n-1).get(m-1) == 1)
                    return;
            }
        }
        if (c==0)
            stack.pop();
        return;
    }

    public static Boolean dfsGoodNodes() {
        Boolean valid = true;
        while (!Gstack.isEmpty()) {
            int p = Gstack.peek().get(0);
            int q = Gstack.peek().get(1);
            Gstack.pop();
            for (int i=0; i<n;i++) {
                ArrayList<Integer> zeros = new ArrayList<>(Arrays.asList(new Integer[m]));
                Collections.fill(zeros, 0);
                vis.add(zeros);
            }
            dfs(p, q);
            int v = vis.get(n-1).get(m-1);
            vis.clear();
            stack.clear();
            if (v<1)
                return false;
        }
        return valid;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        int t = in.nextInt();
        while (t>0) {
            n  =in.nextInt();
            m = in.nextInt();
            for (int i=0; i<n;i++) {
                ArrayList<Character> temp = new ArrayList<Character>();
                String line = in.next();
                char[] tokens = line.toCharArray();
                for (int j=0;j<m;j++) {
                    if (tokens[j] == 'B')
                        Bstack.push(Arrays.asList(i, j));
                    else if (tokens[j] == 'G')
                        Gstack.push(Arrays.asList(i, j));
                    temp.add(tokens[j]);
                }
                maze.add(temp);
            }
            if (findBadNodes()) {
                if (dfsGoodNodes())
                    System.out.println("Yes");
                else
                    System.out.println("No");
            } else {
                if (Gstack.isEmpty())
                    System.out.println("Yes");
                else
                    System.out.println("No");
            }

            Bstack.clear();
            Gstack.clear();
            maze.clear();
            vis.clear();
            t--;
        }
        in.close();
    }
}


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

public class D {
    final static int dx[] = {0, 0, 1, -1};
    final static int dy[] = {1, -1, 0, 0};
    public static ArrayList<List<Character>> maze = new ArrayList<List<Character>>();
    public static ArrayList<List<Integer>> vis = new ArrayList<List<Integer>>();
    public static Deque<List<Integer>> Bstack = new LinkedList<List<Integer>>();
    public static int n, m, count = 0;

    public static void printMaze() {
        for (int i=0; i<n; i++) {
            System.out.println();
            for (int j=0; j<m; j++)
                System.out.print(maze.get(i).get(j) + " ");
        }
    }

    public static Boolean isValid(int i, int j) {
        if (i>=0 && i<n && j>=0 && j<m)
            return true;
        else
            return false;
    }

    public static Boolean findBadNodes() {
        Boolean valid = true;
        outerloop:
        while (!Bstack.isEmpty()) {
            int p = Bstack.peek().get(0);
            int q = Bstack.peek().get(1);
            Bstack.pop();
            maze.get(p).set(q, '#');
            for (int i=0; i<4; i++) {
                int pi = p+dx[i];
                int qi = q+dy[i];
                if (isValid(pi, qi)) {
                    char tmp = maze.get(pi).get(qi);
                    if (tmp == 'G' || (pi == n-1 && qi == m-1)) {
                        valid = false;
                        break outerloop;
                    }
                    if (tmp == '.')
                        maze.get(pi).set(qi, '#');
                }
            }
        }
        return valid;
    }

    public static void dfs(int p, int q) {
        vis.get(p).set(q, 1);
        for (int i=0; i<4; i++) {
            int pi = p + dx[i];
            int qi = q + dy[i];
            if (isValid(pi, qi) && vis.get(pi).get(qi) < 1 && maze.get(pi).get(qi) != '#') {
                if (maze.get(pi).get(qi) == 'G')
                    count--;
                dfs(pi, qi);
            }
        }
        return;
    }

    public static Boolean dfsGoodNodes() {
        for (int i=0; i<n;i++) {
            ArrayList<Integer> zeros = new ArrayList<>(Arrays.asList(new Integer[m]));
            Collections.fill(zeros, 0);
            vis.add(zeros);
        }
        dfs(n-1, m-1);
        if (count>0)
            return false;
        else
            return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        int t = in.nextInt();
        while (t>0) {
            count = 0;
            n  =in.nextInt();
            m = in.nextInt();
            for (int i=0; i<n;i++) {
                ArrayList<Character> temp = new ArrayList<Character>();
                String line = in.next();
                char[] tokens = line.toCharArray();
                for (int j=0;j<m;j++) {
                    if (tokens[j] == 'B')
                        Bstack.push(Arrays.asList(i, j));
                    else if (tokens[j] == 'G')
                        count++;
                    temp.add(tokens[j]);
                }
                maze.add(temp);
            }
            if (findBadNodes()) {
                if (dfsGoodNodes())
                    System.out.println("Yes");
                else
                    System.out.println("No");
            } else {
                if (count == 0)
                    System.out.println("Yes");
                else
                    System.out.println("No");
            }

            Bstack.clear();
            maze.clear();
            vis.clear();
            t--;
        }
        in.close();
    }
}


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

public class D {
    final static int dx[] = {0, 0, 1, -1};
    final static int dy[] = {1, -1, 0, 0};
    public static ArrayList<List<Character>> maze = new ArrayList<List<Character>>();
    public static ArrayList<List<Integer>> vis = new ArrayList<List<Integer>>();
    public static ArrayList<List<Integer>> Gvis = new ArrayList<List<Integer>>();
    public static Deque<List<Integer>> Bstack = new LinkedList<List<Integer>>();
    public static Deque<List<Integer>> Gstack = new LinkedList<List<Integer>>();
    public static Deque<List<Integer>> stack = new LinkedList<List<Integer>>();
    public static int n, m;

    public static void printMaze() {
        for (int i=0; i<n; i++) {
            System.out.println();
            for (int j=0; j<m; j++)
                System.out.print(maze.get(i).get(j) + " ");
        }
    }

    public static Boolean isValid(int i, int j) {
        if (i>=0 && i<n && j>=0 && j<m)
            return true;
        else
            return false;
    }

    public static Boolean findBadNodes() {
        Boolean valid = true;
        outerloop:
        while (!Bstack.isEmpty()) {
            int p = Bstack.peek().get(0);
            int q = Bstack.peek().get(1);
            Bstack.pop();
            maze.get(p).set(q, '#');
            for (int i=0; i<4; i++) {
                int pi = p+dx[i];
                int qi = q+dy[i];
                if (isValid(pi, qi)) {
                    char tmp = maze.get(pi).get(qi);
                    if (tmp == 'G' || (pi == n-1 && qi == m-1)) {
                        valid = false;
                        break outerloop;
                    }
                    if (tmp == '.')
                        maze.get(pi).set(qi, '#');
                }
            }
        }
        return valid;
    }

    public static void dfs(int p, int q) {
        stack.push(Arrays.asList(p, q));
        vis.get(p).set(q, 1);
        if (p == n-1 && q == m-1)
            return;
        int c = 0;
        for (int i=0; i<4; i++) {
            int pi = p + dx[i];
            int qi = q + dy[i];
            if (isValid(pi, qi) && vis.get(pi).get(qi) < 1 && maze.get(pi).get(qi) != '#') {
                if (maze.get(pi).get(qi) == 'G')
                    Gvis.add(Arrays.asList(pi, qi));
                c++;
                dfs(pi, qi);
                if (vis.get(n-1).get(m-1) == 1)
                    return;
            }
        }
        if (c==0)
            stack.pop();
        return;
    }

    public static Boolean dfsGoodNodes() {
        Boolean valid = true;
        while (!Gstack.isEmpty()) {
            int p = Gstack.peek().get(0);
            int q = Gstack.peek().get(1);
            Gstack.pop();
            if (!Gvis.contains(Arrays.asList(p, q))) {
                for (int i=0; i<n;i++) {
                    ArrayList<Integer> zeros = new ArrayList<>(Arrays.asList(new Integer[m]));
                    Collections.fill(zeros, 0);
                    vis.add(zeros);
                }
                dfs(p, q);
                int v = vis.get(n-1).get(m-1);
                vis.clear();
                stack.clear();
                if (v<1)
                    return false;
            }
        }
        return valid;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        int t = in.nextInt();
        while (t>0) {
            n  =in.nextInt();
            m = in.nextInt();
            for (int i=0; i<n;i++) {
                ArrayList<Character> temp = new ArrayList<Character>();
                String line = in.next();
                char[] tokens = line.toCharArray();
                for (int j=0;j<m;j++) {
                    if (tokens[j] == 'B')
                        Bstack.push(Arrays.asList(i, j));
                    else if (tokens[j] == 'G')
                        Gstack.push(Arrays.asList(i, j));
                    temp.add(tokens[j]);
                }
                maze.add(temp);
            }
            if (findBadNodes()) {
                if (dfsGoodNodes())
                    System.out.println("Yes");
                else
                    System.out.println("No");
            } else {
                if (Gstack.isEmpty())
                    System.out.println("Yes");
                else
                    System.out.println("No");
            }

            Bstack.clear();
            Gstack.clear();
            maze.clear();
            vis.clear();
            Gvis.clear();
            t--;
        }
        in.close();
    }
}


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

public class d
{
    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;
        }
    }

    //  long start = System.currentTimeMillis();
//  long end = System.currentTimeMillis();
//  System.out.println((end - start) + "ms");
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int t = s.nextInt();
        for(int tt=0;tt<t;tt++){
            int n = s.nextInt();
            int m = s.nextInt();
            char[][] grid = new char[n][m];
            for(int i=0;i<n;i++){
                grid[i] = s.nextLine().toCharArray();
            }
            System.out.println(solve(n,m,grid));
        }

    }
    public static String solve(int n,int m,char[][] grid){
        //make all blacks surroundings build a wall
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(grid[i][j]=='B'){
                    if(i-1>=0 && grid[i-1][j]=='.'){
                        grid[i-1][j] = '#';
                    }
                    if(i+1<n && grid[i+1][j]=='.'){
                        grid[i+1][j] = '#';
                    }
                    if(j-1>=0 && grid[i][j-1]=='.'){
                        grid[i][j-1] = '#';
                    }
                    if(j+1<m && grid[i][j+1]=='.'){
                        grid[i][j+1] = '#';
                    }
                }
            }
        }
        //now make bfs on (n,m)

        boolean[][] visited = new boolean[n][m];
        if(grid[n-1][m-1]!='#'){
            Queue<Pair> queue = new LinkedList<>();
            queue.add(new Pair(n-1,m-1));
            visited[n-1][m-1] = true;
            while (!queue.isEmpty()){
                Pair p = queue.remove();
                int i = p.x;
                int j = p.y;
                if(i-1>=0 && grid[i-1][j]!='#'){
                    if(!visited[i-1][j]){
                        queue.add(new Pair(i-1,j));
                        visited[i-1][j] = true;
                    }
                }
                if(i+1<n && grid[i+1][j]!='#'){
                    if(!visited[i+1][j]){
                        queue.add(new Pair(i+1,j));
                        visited[i+1][j] = true;
                    }
                }
                if(j-1>=0 && grid[i][j-1]!='#'){
                    if(!visited[i][j-1]){
                        queue.add(new Pair(i,j-1));
                        visited[i][j-1] = true;
                    }
                }
                if(j+1<m && grid[i][j+1]!='#'){
                    if(!visited[i][j+1]){
                        queue.add(new Pair(i,j+1));
                        visited[i][j+1] = true;
                    }
                }

            }
        }
//        debug(visited);
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(grid[i][j]=='G' && !visited[i][j]){
                    return "No";
                }
                if(grid[i][j]=='B' && visited[i][j]){
                    return "No";
                }
            }
        }
        return "Yes";
    }

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

    public static void print(String str,int val){
        System.out.println(str+"  "+val);
    }

    public static void print(Object[] obj){
        for(Object a:obj){
            System.out.println(a);
        }
    }

    public static void print(Object[][] obj){
        for(Object[] a:obj){
            System.out.println(Arrays.toString(a));
        }
    }

    public static void debug(long[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(int[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(boolean[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(arr[i]);
        }
    }

    public static void print(int[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(long[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }

//    OutputStream out = new BufferedOutputStream( System.out );
//        for(int i=1;i<n;i++){
//    out.write((max_divisor[i]+" ").getBytes());
//}
//        out.flush();

}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				if(ans==true){
					out.println("Yes");
				}
				else{
					out.println("No");
				}

			}
		}
		out.close();

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int[] c: getAdj(a,b)){
			int x = c[0];
			int y = c[1];
			if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
				boolean bool = dfs(x,y,visited);
				if(!bool)
					continue;
				else {
					return bool;
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int[] c: getAdj(a,b)){
			if(arr[c[0]][c[1]]=='B')
				return false;
		}
		return true;
	}

	static ArrayList<int[]> getAdj(int a, int b){
		ArrayList<int[]> list = new ArrayList<int[]>();
		if(a>0)
			list.add(new int[]{a-1,b});
		if(b>0)
			list.add(new int[]{a,b-1});
		if(a<n-1)
			list.add(new int[]{a+1,b});
		if(b<m-1)
			list.add(new int[]{a,b+1});
		return list;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				System.out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				System.out.println(ans?"Yes":"No");

			}
		}

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int[] c: getAdj(a,b)){
			int x = c[0];
			int y = c[1];
			if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
				boolean bool = dfs(x,y,visited);
				if(!bool)
					continue;
				else {
					return bool;
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int[] c: getAdj(a,b)){
			if(arr[c[0]][c[1]]=='B')
				return false;
		}
		return true;
	}

	static ArrayList<int[]> getAdj(int a, int b){
		ArrayList<int[]> list = new ArrayList<int[]>();
		if(a>0)
			list.add(new int[]{a-1,b});
		if(b>0)
			list.add(new int[]{a,b-1});
		if(a<n-1)
			list.add(new int[]{a+1,b});
		if(b<m-1)
			list.add(new int[]{a,b+1});
		return list;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				System.out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				out.println(ans?"Yes":"No");

			}
		}
		out.close();

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int[] c: getAdj(a,b)){
			int x = c[0];
			int y = c[1];
			if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
				boolean bool = dfs(x,y,visited);
				if(!bool)
					continue;
				else {
					return bool;
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int[] c: getAdj(a,b)){
			if(arr[c[0]][c[1]]=='B')
				return false;
		}
		return true;
	}

	static ArrayList<int[]> getAdj(int a, int b){
		ArrayList<int[]> list = new ArrayList<int[]>();
		if(a>0)
			list.add(new int[]{a-1,b});
		if(b>0)
			list.add(new int[]{a,b-1});
		if(a<n-1)
			list.add(new int[]{a+1,b});
		if(b<m-1)
			list.add(new int[]{a,b+1});
		return list;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				System.out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				System.out.println(ans?"Yes":"No");

			}
		}

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int[] c: getAdj(a,b)){
			int x = c[0];
			int y = c[1];
			if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
				boolean bool = dfs(x,y,visited);
				if(!bool)
					continue;
				else {
					return bool;
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int[] c: getAdj(a,b)){
			if(arr[c[0]][c[1]]=='B')
				return false;
		}
		return true;
	}

	static ArrayList<int[]> getAdj(int a, int b){
		ArrayList<int[]> list = new ArrayList<int[]>();
		if(a>0)
			list.add(new int[]{a-1,b});
		if(b>0)
			list.add(new int[]{a,b-1});
		if(a<n-1)
			list.add(new int[]{a+1,b});
		if(b<m-1)
			list.add(new int[]{a,b+1});
		return list;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	static int[] dr = {0,0,1,-1};
	static int[] dc = {1,-1,0,0};

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				if(ans==true){
					out.println("Yes");
				}
				else{
					out.println("No");
				}

			}
		}
		out.close();

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<m){
				if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
					boolean bool = dfs(x,y,visited);
					if(!bool)
						continue;
					else {
						return bool;
					}
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<m){
				if(arr[x][y]=='B')
					return false;
			}
		}
		return true;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	static int[] dr = {0,0,1,-1};
	static int[] dc = {1,-1,0,0};

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				if(ans==true){
					out.println("Yes");
				}
				else{
					out.println("No");
				}

			}
		}
		out.close();

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int i=0;i<3;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<m){
				if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
					boolean bool = dfs(x,y,visited);
					if(!bool)
						continue;
					else {
						return bool;
					}
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<n){
				if(arr[x][y]=='B')
					return false;
			}
		}
		return true;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	static int[] dr = {0,0,1,-1};
	static int[] dc = {1,-1,0,0};

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();

		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();

			arr = new char[n][];

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

			ArrayList<int[]> goodList = new ArrayList<int[]>();

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='G')
						goodList.add(new int[]{i,j});
				}
			}

			if(goodList.size()==0){
				out.println("Yes");
			}
			else{
				boolean ans = true;
				for(int[] a: goodList){
					ans = ans && isWayPossible(a[0],a[1]);
					if(!ans)
						break;
				}

				if(ans==true){
					out.println("Yes");
				}
				else{
					out.println("No");
				}

			}
		}
		out.close();

	}

	static boolean isWayPossible(int a, int b){

		boolean[][] visited = new boolean[n][m];
		if(!isPointGood(a,b))
			return false;
		return dfs(a,b,visited);
	}

	static boolean dfs(int a, int b, boolean[][] visited){
		visited[a][b] = true;

		if(a==n-1 && b==m-1)
			return true;

		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<m){
				if(!visited[x][y] && arr[x][y]!='#' && arr[x][y]!='B' && isPointGood(x,y)){
					boolean bool = dfs(x,y,visited);
					if(!bool)
						continue;
					else {
						return bool;
					}
				}
			}
		}
		return false;
	}

	static boolean isPointGood(int a,int b){
		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<n){
				if(arr[x][y]=='B')
					return false;
			}
		}
		return true;
	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.Math;
import java.util.Random;

public class Solution{

	static int n;
	static int m;
	static char[][] arr;

	static int[] dr = {0,0,1,-1};
	static int[] dc = {1,-1,0,0};

	public static void main(String[] args) throws Exception{

		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int t = fs.nextInt();

		while(t-->0){

			n = fs.nextInt();
			m = fs.nextInt();
			arr = new char[n][];

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

			//BLOCKING ALL THE BAD PEOPLE
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(arr[i][j]=='B')
						block(i,j);
				}
			}

			//TRAVERSING THE GRAPH THROUGH BFS
			Queue<int[]> queue = new LinkedList<int[]>();
			boolean[][] visited = new boolean[n][m];

			if(arr[n-1][m-1]=='.')
				queue.add(new int[]{n-1,m-1});
			visited[n-1][m-1] = true;

			while(!queue.isEmpty()){
				int[] a = queue.poll();
				for(int i=0;i<4;i++){
					int x = a[0]+dr[i];
					int y = a[1]+dc[i];
					if(x>=0 && x<n && y>=0 && y<m && !visited[x][y] && arr[x][y]!='#'){
						visited[x][y] = true;
						queue.add(new int[]{x,y});
					}
				}
			}

			boolean ans = true;

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if((arr[i][j] == 'G' && !visited[i][j]) || (arr[i][j]=='B' && visited[i][j])){
						ans = false;
						break;
					}
				}
			}
			out.println(ans?"Yes":"No");
		}

		out.close();

	}

	static void block(int a, int b){
		for(int i=0;i<4;i++){
			int x = a+dr[i];
			int y = b+dc[i];
			if(x>=0 && x<n && y>=0 && y<m && arr[x][y]=='.'){
				arr[x][y] = '#';
			}
		}

	}

	static class FastScanner{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next(){
			while(!st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				} catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public int[] readArray(int n){
			int[] a = new int[n];
			for(int i=0;i<n;i++)
				a[i] = nextInt();
			return a;
		}

		public long nextLong(){
			return Long.parseLong(next());
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author unknown
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DSolveTheMaze solver = new DSolveTheMaze();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSolveTheMaze {
        int[] dx = {-1, 0, 1, 0};
        int[] dy = {0, 1, 0, -1};
        char[][] mat;
        int n;
        int m;
        boolean[][] vis;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int ntc = in.nextInt();
            while ((ntc--) > 0) {
                n = in.nextInt();
                m = in.nextInt();
                int gc = 0;
                int bc = 0;
                mat = new char[n][m];
                vis = new boolean[n][m];
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        char ch = in.nextCharacter();
                        if (ch == 'G') {
                            gc++;
                        }
                        if (ch == 'B') {
                            bc++;
                        }
                        mat[i][j] = ch;
                    }
                }
                if (gc == 0) {
                    out.println("Yes");
                    continue;
                }
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < m; j++) {
                        if (mat[i][j] == 'B') {
                            for (int k = 0; k < 4; k++) {
                                int newx = dx[k] + i;
                                int newy = dy[k] + j;
                                if (isvalid(newx, newy) && mat[newx][newy] == '.') {
                                    mat[newx][newy] = '#';
                                }
                            }
                        }
                    }
                }
                boolean ok = true;
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        vis = new boolean[n][m];
                        if (mat[i][j] == 'G' && !bfs(i, j)) {
                            ok = false;
                            break;
                        }
//                    else if(mat[i][j] =='B' && bfs(i,j)){
//                        ok = false;
//                        break;
//                    }
                    }
                }
                if (ok) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
//            for(int i = )
            }
        }

        boolean bfs(int x, int y) {
            ArrayDeque<Integer> queue = new ArrayDeque<>();
            queue.addLast(x);
            queue.addLast(y);
            vis[x][y] = true;
            while (!queue.isEmpty()) {
                int u = queue.removeFirst();
                int v = queue.removeFirst();
                vis[u][v] = true;
                for (int i = 0; i < 4; i++) {
                    int newx = u + dx[i];
                    int newy = v + dy[i];
                    if (isvalid(newx, newy) && mat[newx][newy] != '#' && !vis[newx][newy]) {
                        if (newx == n - 1 && newy == m - 1) {
                            return true;
                        }
                        queue.addLast(newx);
                        queue.addLast(newy);
                    }
                }
            }
            return false;
        }

        boolean isvalid(int x, int y) {
            if (x < 0 || x >= n) {
                return false;
            }
            if (y < 0 || y >= m) {
                return false;
            }
            return true;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

        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) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public char nextCharacter() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            return (char) c;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; ++i) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}