
import javafx.util.Pair;

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


public class tt_1365D {
    static Scanner sc;
    static FastReader fr;
    public static void main(String[] args){
        sc = new Scanner(System.in);
        fr = new FastReader();
        int test = fr.nextInt();
        for(int t=0; t<test; t++){

            int n = fr.nextInt();
            int m = fr.nextInt();
            int[][] mat = new int[n][m];
            HashSet<Pair<Integer, Integer>> badPeople = new HashSet<>(2500);
            int count = 0;
            for(int i=0; i<n; i++){
                char[] arr = getCharArray();
                for(int j=0; j<m; j++){
                    switch (arr[j]){
                        case 'G':
                            mat[i][j] = 1;
                            count++;
                            break;
                        case 'B':
                            badPeople.add(new Pair<>(i,j));
                            mat[i][j] = 2;
                            break;
                        case '.':
                            mat[i][j] = 3;
                            break;
                        case '#':
                            mat[i][j] = 4;
                            break;
                    }
                }
            }
            // All bad people are captured now
            for(Pair<Integer, Integer> badPerson : badPeople){
                // surround them by wall
                int x = badPerson.getKey();
                int y = badPerson.getValue();
                if(x-1>-1){
                    mat[x-1][y] = 4;
                }
                if(x+1<n){
                    mat[x+1][y]=4;
                }
                if(y-1>-1){
                    mat[x][y-1]=4;
                }
                if(y+1<m){
                    mat[x][y+1]=4;
                }
            }
            // see if all good people are reachable from n-1,m-1 !
            HashSet<Pair<Integer,Integer>> visitedNodes = new HashSet<>(2500);
            int countGoodReachable = getAllGoodReachable(mat, n-1, m-1, visitedNodes, n , m);
            if(count==countGoodReachable){
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
    }

    private static int getAllGoodReachable(int[][] mat, int x, int y, HashSet<Pair<Integer, Integer>> visitedNodes, int n, int m) {
        // if curr is visited it means we have trvelled from it and all reachable points from it.
        int res = 0;
        if(visitedNodes.contains(new Pair<>(x,y))){
            return res;
        }

        visitedNodes.add(new Pair<>(x,y));
        if(mat[x][y]==4){
            return res;
        }
        if(mat[x][y]==1){
            res++;
        }
        if(x-1>-1 && mat[x-1][y] != 4){
            res+=getAllGoodReachable(mat, x-1, y, visitedNodes, n, m);
        }
        if(x+1<n && mat[x+1][y] != 4){
            res+=getAllGoodReachable(mat, x+1, y, visitedNodes, n, m);
        }
        if(y-1>-1 && mat[x][y-1] != 4){
            res+=getAllGoodReachable(mat, x, y-1, visitedNodes, n ,m);
        }
        if(y+1<m && mat[x][y+1] != 4){
            res+=getAllGoodReachable(mat, x, y+1, visitedNodes, n ,m);
        }
        return res;
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static Integer[] getIntArrayFromSingleLine(){
        List<Integer> list = new LinkedList<>();
        String[] str = fr.nextLine().split(" ");
        for(String s: str){
            list.add(Integer.parseInt(s));
        }
        Integer[] arr = new Integer[list.size()];
        return list.toArray(arr);
    }

    public static Long[] getLongArrayFromSingleLine(){
        List<Long> list = new LinkedList<>();
        String[] str = fr.nextLine().split(" ");
        for(String s: str){
            list.add(Long.parseLong(s));
        }
        Long[] longs = new Long[list.size()];
        return list.toArray(longs);
    }

    public static Double[] getDoubleArrayFromSingleLine(){
        List<Double> list = new LinkedList<>();
        String[] str= fr.nextLine().split(" ");
        for(String s: str){
            list.add(Double.parseDouble(s));
        }
        Double[] doubles = new Double[list.size()];
        return list.toArray(doubles);
    }

    public static int[] getArray(int n){
        int[] arr = new int[n];
        for(int i=0; i<n; i++){
            arr[i] = fr.nextInt();
        }
        return arr;
    }

    public static long[] getLongArray(int n){
        long[] res = new long[n];
        for(int i=0; i<n; i++){
            res[i] = fr.nextLong();
        }
        return res;
    }

    public static double[] getDoubleArray(int n){
        double[] arr = new double[n];
        for(int i=0; i<n ; i++){
            arr[i] = fr.nextDouble();
        }
        return arr;
    }

    public static char[] getCharArray(){
        return fr.next().toCharArray();
    }

    public static String[] getStringArray(int n){
        String[] strings = new String[n];
        for(int i=0; i<n; i++){
            strings[i] = fr.next();
        }
        return strings;
    }

    // Get GCD
    public static int getGCD(int a, int b){
        return (a==0 ? b : getGCD(b%a, a));
    }

    public static int getGCD(int[] arr){
        int n = arr.length;
        if(n==0){
            return -1;
        }
        int res = arr[0];
        for(int i=1; i<n; i++){
            res = getGCD(res, arr[i]);
        }
        return res;
    }

    // Get all prime numbers till N using seive of Eratosthenes
    public static List<Integer> getPrimesTill(int n){
        boolean[] arr = new boolean[n+1];
        List<Integer> primes = new LinkedList<>();
        for(int i=2; i<=n; i++){
            if(!arr[i]){
                primes.add(i);
                for(int j=(i*i); j<=n; j+=i){
                    arr[j] = true;
                }
            }
        }
        return primes;
    }


    // This method returns list of PrimeFactors of a number in O(sqrt(N));
    public static Map<Integer,Integer> getPrimeFactors(long n){
        Map<Integer,Integer> res = new HashMap<>();
        int sqrt = (int) Math.sqrt(n);
        if(n%2 == 0){
            int c = 0;
            while(n%2==0){
                c++;
                n/=2;
            }
            res.put(2,c);
        }
        for(int i=3; i<=sqrt; i+=2){
            if(n%i == 0) {
                int c = 0;
                while (n % i == 0) {
                    c++;
                    n /= i;
                }
                res.put(i,c);
            }
        }
        if(n!=1){
            res.put((int)n,1);
        }
        return res;
    }

}