import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class _D_ {

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

		final int[][] moves = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

		for (int z = in.nextInt(); z > 0; z--) {
			final int n = in.nextInt(), m = in.nextInt();
			final char[][] matrix = new char[n][m];
			final List<int[]> bad = new ArrayList<>();
			int good = 0;
			for (int j = 0; j < n; j++) {
				matrix[j] = in.next().toCharArray();
				for (int i = 0; i < m; i++) {
					if (matrix[j][i] == 'G')
						good++;
					else if (matrix[j][i] == 'B')
						bad.add(new int[] { i, j });
				}
			}
			bad.forEach(b -> {
				for (final int[] move : moves) {
					final int xnew = b[0] + move[0], ynew = b[1] + move[1];
					if (0 <= ynew && ynew < n && 0 <= xnew && xnew < m && matrix[ynew][xnew] == '.') {
						matrix[ynew][xnew] = '#';
					}
				}
			});

			final Deque<int[]> queue = new ArrayDeque<>();
			int[] iterator = new int[] { m - 1, n - 1 };
			final boolean[][] done = new boolean[n][m];
			done[iterator[1]][iterator[0]] = true;
			do {
				for (final int[] move : moves) {
					final int xnew = iterator[0] + move[0], ynew = iterator[1] + move[1];
					if (0 <= ynew && ynew < n && 0 <= xnew && xnew < m && matrix[ynew][xnew] != '#' && !done[ynew][xnew]) {
						queue.addLast(new int[] { xnew, ynew });
						done[ynew][xnew] = true;
						if (matrix[ynew][xnew] == 'G')
							good--;
						else if (matrix[ynew][xnew] == 'B')
							good = Integer.MAX_VALUE;
					}
				}
			} while (good < 2500 && (iterator = queue.pollFirst()) != null);

			System.out.println(good == 0 ? "yes" : "no");
		}
	}
}