#include <bits/stdc++.h>
template <typename T>
std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
}
using namespace std;
vector<pair<int, int> > adjacentCells(int i, int j, int n, int m) {
  vector<pair<int, int> > result;
  if (i > 0) {
    result.push_back({i - 1, j});
  }
  if (i < n - 1) {
    result.push_back({i + 1, j});
  }
  if (j > 0) {
    result.push_back({i, j - 1});
  }
  if (j < m - 1) {
    result.push_back({i, j + 1});
  }
  return result;
}
void dfs(const vector<vector<char> >& maze, int i, int j, int n, int m,
         vector<vector<int> >& visited, set<pair<int, int> >& goods) {
  if (maze[i][j] == 'G') {
    goods.insert({i, j});
  }
  visited[i][j] = true;
  if (maze[i][j] == '#') {
    return;
  }
  vector<pair<int, int> > nrs = adjacentCells(i, j, n, m);
  for (auto nr : nrs) {
    if ((!visited[nr.first][nr.second])) {
      dfs(maze, nr.first, nr.second, n, m, visited, goods);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  for (int case_num = 1; case_num < T + 1; case_num++) {
    int n, m;
    cin >> n >> m;
    int countGood = 0;
    vector<vector<char> > maze(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
      string row;
      cin >> row;
      for (int j = 0; j < m; j++) {
        maze[i][j] = row[j];
        if (row[j] == 'G') {
          countGood++;
        }
      }
    }
    bool adjacent = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (maze[i][j] == 'B') {
          for (auto nr : adjacentCells(i, j, n, m)) {
            if (maze[nr.first][nr.second] == '.') {
              maze[nr.first][nr.second] = '#';
            }
            if (maze[nr.first][nr.second] == 'G') {
              adjacent = true;
            }
          }
        }
        if (adjacent) {
          break;
        }
      }
      if (adjacent) {
        break;
      }
    }
    if (adjacent) {
      cout << "No" << endl;
    } else {
      set<pair<int, int> > goods;
      vector<vector<int> > visited(n, vector<int>(m));
      dfs(maze, n - 1, m - 1, n, m, visited, goods);
      if (int((goods).size()) == countGood) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}
