#include <bits/stdc++.h>
int main() {
  int t;
  std::cin >> t;
  while (t-- > 0) {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<char>> map(n, std::vector<char>(m));
    std::string s;
    std::getline(std::cin, s);
    int toSave = 0;
    for (int i = 0; i < n; i++) {
      std::getline(std::cin, s);
      for (int j = 0; j < m; j++) map[i][j] = s[j], toSave += map[i][j] == 'G';
    }
    bool bad = false;
    for (int y = 0; y < n; y++)
      for (int x = 0; x < m; x++)
        if (map[y][x] == 'B')
          for (int dy = -1; dy <= 1; dy++)
            for (int dx = -1; dx <= 1; dx++) {
              if (dy * dy + dx * dx != 1) continue;
              int ny = y + dy, nx = x + dx;
              if (nx < 0 || ny < 0 || ny >= n || nx >= m) continue;
              if (bad) break;
              if (map[ny][nx] == 'G') {
                bad = true;
                break;
              }
              if (map[ny][nx] == '.') map[ny][nx] = '#';
            }
    if (bad) {
      printf("No\n");
      continue;
    }
    std::queue<std::pair<int, int>> dq;
    dq.push({n - 1, m - 1});
    std::set<std::pair<int, int>> marks;
    marks.insert({n - 1, m - 1});
    while (!dq.empty()) {
      auto [cr, cc] = dq.front();
      dq.pop();
      if (map[cr][cc] == '#') continue;
      if (map[cr][cc] == 'G') toSave--;
      for (int dy = -1; dy <= 1; dy++)
        for (int dx = -1; dx <= 1; dx++) {
          if (dy * dy + dx * dx != 1) continue;
          int ny = cr + dy, nx = cc + dx;
          if (nx < 0 || ny < 0 || ny >= n || nx >= m) continue;
          if (map[ny][nx] == '#' || map[ny][nx] == 'B') continue;
          if (marks.count({ny, nx})) continue;
          marks.insert({ny, nx});
          dq.push({ny, nx});
        }
    }
    printf("%s", toSave == 0 ? "Yes\n" : "No\n");
  }
}
