#include <bits/stdc++.h>
using namespace std;
char s[60][60];
int f[][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, vis[60][60];
struct U {
  int first, second;
  inline void u(int x, int y) { first = x, second = y; }
} P[2600];
int t, n, m, flag, idx;
bool finds(int first, int second) {
  int fl = 0;
  if (first > n || second > m || first < 1 || second < 1 ||
      s[first][second] == '#' || vis[first][second])
    return false;
  if (first == n && second == m) return true;
  vis[first][second] = 1;
  for (int j = 0; j < 4; j++) {
    if (fl != 1 && finds(first + f[j][0], second + f[j][1])) fl = 1;
  }
  if (fl)
    return true;
  else
    return false;
}
bool check(int x) {
  for (int i = 0; i < x; i++) {
    memset(vis, 0, sizeof vis);
    if (!finds(P[i].first, P[i].second)) return false;
  }
  return true;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    memset(P, 0, sizeof P);
    memset(s, 0, sizeof s);
    flag = 0, idx = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> s[i][j];
        if (s[i][j] == 'G') P[idx++].u(i, j);
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            if (s[i + f[k][0]][j + f[k][1]] == 'G') {
              flag = 1;
            } else if (s[i + f[k][0]][j + f[k][1]] == '.') {
              s[i + f[k][0]][j + f[k][1]] = '#';
            }
          }
        }
      }
    }
    if (idx == 0 && s[n][m] != 'B')
      printf("Yes\n");
    else if (flag)
      printf("No\n");
    else if (check(idx))
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
