#include <bits/stdc++.h>
using namespace std;
char a[100][100];
int n, m;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int vis[1001][1001];
void bfs(int x, int y) {
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  vis[x][y] = 1;
  while (q.size() > 0) {
    pair<int, int> top = q.front();
    q.pop();
    for (int k = 0; k < 4; k++) {
      int tx = top.first + fx[k];
      int ty = top.second + fy[k];
      if (a[tx][ty] != '#' && tx >= 0 && tx < n && ty >= 0 && ty < m &&
          vis[tx][ty] == 0) {
        vis[tx][ty] = 1;
        q.push(pair<int, int>(tx, ty));
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          if (a[i][j + 1] == '.' && j + 1 < m) a[i][j + 1] = '#';
          if (a[i][j - 1] == '.' && j - 1 >= 0) a[i][j - 1] = '#';
          if (a[i - 1][j] == '.' && i - 1 >= 0) a[i - 1][j] = '#';
          if (a[i + 1][j] == '.' && i + 1 < n) a[i + 1][j] = '#';
        }
      }
    }
    int flag = 1;
    memset(vis, 0, sizeof(vis));
    if (a[n - 1][m - 1] == '.') bfs(n - 1, m - 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if ((a[i][j] == 'G' && vis[i][j] == 0) ||
            (a[i][j] == 'B' && vis[i][j] == 1)) {
          flag = 0;
          break;
        }
      }
    }
    if (flag == 1)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
