#include <bits/stdc++.h>
using namespace std;
string s[60];
queue<pair<int, int> > q;
int d[60][60];
pair<int, int> p[60][60];
int vis[55][55], n, m;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
void bfs(int a, int b) {
  d[a][b] = 0;
  q.push({a, b});
  vis[a][b] = 1;
  p[a][b] = {-1, -1};
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int x = u.first + dx[i];
      int y = u.second + dy[i];
      if (x < 0 or y < 0 or x >= n or y >= m) continue;
      if (s[x][y] == '#') continue;
      if (!vis[x][y]) {
        vis[x][y] = 1;
        q.push({x, y});
        d[x][y] = d[u.first][u.second] + 1;
        p[x][y] = u;
      }
    }
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    s[i].clear();
  }
  memset(p, 0, sizeof(p)), memset(d, 0, sizeof(d)), memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; i++) cin >> s[i];
  bfs(n - 1, m - 1);
  int blocked[60][60];
  memset(blocked, 0, sizeof(blocked));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      blocked[i][j] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'G') {
        pair<int, int> temp = {-1, -1};
        vector<pair<int, int> > path;
        if (vis[i][j] == 0) {
          cout << "No"
               << "\n";
          return;
        }
        for (pair<int, int> v = {i, j}; v != temp; v = p[v.first][v.second]) {
          path.push_back({v.first, v.second});
        }
        for (auto x : path) {
          blocked[x.first][x.second] = 0;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        blocked[i][j] = 0;
        if (i == n - 1 and j == m - 1) {
          cout << "No"
               << "\n";
          return;
        }
        pair<int, int> temp = {-1, -1};
        vector<pair<int, int> > path;
        if (vis[i][j] == 0) continue;
        for (pair<int, int> v = {i, j}; v != temp; v = p[v.first][v.second]) {
          path.push_back({v.first, v.second});
        }
        int flag = 0;
        for (auto x : path) {
          int a = x.first, b = x.second;
          if (a == i and b == j) continue;
          if (blocked[a][b] == 1) {
            flag = 1;
            break;
          }
        }
        if (flag == 0) {
          cout << "No"
               << "\n";
          return;
        }
      }
    }
  }
  cout << "Yes"
       << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
