#include <bits/stdc++.h>
using namespace std;
int n, m;
int t;
int num;
char mp[55][55];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
bool vis[55][55];
void dfs(int x, int y) {
  if (mp[x][y] == 'G') num--;
  vis[x][y] = true;
  int xx, yy;
  for (int i = 0; i < 4; i++) {
    xx = x + dir[i][0];
    yy = y + dir[i][1];
    if (mp[xx][yy] != '#' && !vis[xx][yy] && xx > 0 && yy > 0 && xx <= n &&
        yy <= m)
      dfs(xx, yy);
  }
  return;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    memset(vis, false, sizeof(vis));
    memset(mp, 0, sizeof(mp));
    for (int i = 1; i <= n; i++) cin >> &mp[i][1];
    int flag = 0;
    num = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (mp[i][j] == 'G') num++;
        if (mp[i][j] == 'B' && mp[i - 1][j] != 'G' && mp[i + 1][j] != 'G' &&
            mp[i][j - 1] != 'G' && mp[i][j + 1] != 'G') {
          if (mp[i - 1][j] != 'B') mp[i - 1][j] = '#';
          if (mp[i + 1][j] != 'B') mp[i + 1][j] = '#';
          if (mp[i][j + 1] != 'B') mp[i][j + 1] = '#';
          if (mp[i][j - 1] != 'B') mp[i][j - 1] = '#';
        } else if (mp[i][j] == 'B' &&
                   (mp[i - 1][j] == 'G' || mp[i + 1][j] == 'G' ||
                    mp[i][j - 1] == 'G' || mp[i][j + 1] == 'G')) {
          flag = 1;
          break;
        }
      }
      if (flag == 1) break;
    }
    if (flag)
      cout << "No" << endl;
    else {
      if (mp[n][m] == '.') dfs(n, m);
      if (num != 0)
        cout << "No" << endl;
      else
        cout << "Yes" << endl;
    }
  }
}
