#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n, m;
char a[107][107];
bool vis[107][107];
bool boundary(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); }
void clear() {
  for (int i = 0; i < 107; i++) {
    for (int j = 0; j < 107; j++) {
      vis[i][j] = false;
    }
  }
}
void block() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'B') {
        if (i - 1 >= 0 && a[i - 1][j] == '.') a[i - 1][j] = '#';
        if (i + 1 < n && a[i + 1][j] == '.') a[i + 1][j] = '#';
        if (j - 1 >= 0 && a[i][j - 1] == '.') a[i][j - 1] = '#';
        if (j + 1 < m && a[i][j + 1] == '.') a[i][j + 1] = '#';
      }
    }
  }
}
void bfs(int i, int j) {
  vis[i][j] = true;
  queue<pair<long long, long long> > q;
  q.push({i, j});
  while (!q.empty()) {
    pair<long long, long long> v = q.front();
    int x = v.first, y = v.second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int nx = x + dx[k];
      int ny = y + dy[k];
      if (boundary(nx, ny) && !vis[nx][ny] && a[nx][ny] != '#') {
        vis[nx][ny] = true;
        q.push({nx, ny});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    cin >> n >> m;
    int cnt = 0, cnt1 = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] == 'G') cnt++;
        if (a[i][j] == 'B') cnt1++;
      }
    }
    block();
    if (a[n - 1][m - 1] == '.') bfs(n - 1, m - 1);
    bool ok = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if ((a[i][j] == 'G' && !vis[i][j]) || (a[i][j] == 'B' && vis[i][j])) {
          ok = true;
          break;
        }
      }
      if (ok) break;
    }
    clear();
    if (ok)
      cout << "NO" << endl;
    else
      cout << "Yes" << endl;
  }
}
