#include <bits/stdc++.h>
using namespace std;
char a[55][55];
int vis[55][55];
int fx[] = {0, 0, 1, -1};
int fy[] = {1, -1, 0, 0};
vector<pair<int, int> > goodBoys;
bool valid(int x, int y, int n, int m) {
  if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] != '.')
    return false;
  else
    return true;
}
bool valid1(int x, int y, int n, int m) {
  if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] == '#')
    return false;
  else
    return true;
}
void bfs(int sx, int sy, int n, int m) {
  memset(vis, 0, sizeof(vis));
  vis[sx][sy] = 1;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(sx, sy));
  while (!q.empty()) {
    pair<int, int> top = q.front();
    q.pop();
    if (top.first == n - 1 && top.second == m - 1) break;
    for (int k = 0; k < 4; k++) {
      int tx = top.first + fx[k];
      int ty = top.second + fy[k];
      if (valid1(tx, ty, n, m) && vis[tx][ty] != 1) {
        vis[tx][ty] = 1;
        q.push(pair<int, int>(tx, ty));
      }
    }
  }
}
int main() {
  int tc, n, m, i, j, g, b, ans;
  scanf("%d", &tc);
  while (tc--) {
    g = 0, b = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> a[i][j];
        g += (a[i][j] == 'G');
        b += (a[i][j] == 'B');
        if (a[i][j] == 'G') goodBoys.push_back(pair<int, int>(i, j));
      }
    }
    if (g == 0)
      printf("Yes\n");
    else {
      for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
          if (a[i][j] == 'B') {
            for (int k = 0; k < 4; k++) {
              int tx = i + fx[k];
              int ty = j + fy[k];
              if (valid(tx, ty, n, m)) {
                a[tx][ty] = '#';
              }
            }
          }
        }
      }
      bool flag = true;
      for (i = 0; i < goodBoys.size(); i++) {
        int sx = goodBoys[i].first, sy = goodBoys[i].second;
        bfs(sx, sy, n, m);
        if (!vis[n - 1][m - 1]) {
          flag = false;
          break;
        }
      }
      if (!flag)
        printf("No\n");
      else
        printf("Yes\n");
      goodBoys.clear();
    }
  }
  return 0;
}
