#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 10;
char a[maxn][maxn];
int vis[maxn][maxn];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
void solve() {
  int n, m;
  cin >> n >> m;
  int cnt = 0, g = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') g++;
    }
  }
  memset(vis, 0, sizeof(vis));
  queue<vector<int>> q;
  q.push({n - 1, m - 1});
  while (!q.empty()) {
    int x = q.front()[0], y = q.front()[1];
    q.pop();
    if (a[x][y] == '1') continue;
    bool flag = true;
    for (int i = 0; i < 4; i++) {
      int new_x = x + dx[i];
      int new_y = y + dy[i];
      if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m) {
        if (a[new_x][new_y] == 'B') {
          flag = false;
          break;
        }
      }
    }
    if (!flag) {
      if (a[x][y] == 'G') {
        cnt--;
        break;
      }
    }
    if (flag) {
      a[x][y] = '1';
      for (int i = 0; i < 4; i++) {
        int new_x = x + dx[i];
        int new_y = y + dy[i];
        if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m &&
            vis[new_x][new_y] == 0) {
          if (a[new_x][new_y] == '.') {
            q.push({new_x, new_y});
            vis[new_x][new_y] = 1;
          } else if (a[new_x][new_y] == 'G') {
            cnt++;
            q.push({new_x, new_y});
            vis[new_x][new_y] = 1;
          }
        }
      }
    }
  }
  cout << (cnt == g ? "Yes" : "No") << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
