#include <bits/stdc++.h>
using namespace std;
int n, m;
int t;
char mp[55][55];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
bool vis[55][55];
struct node {
  int x, y;
};
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    memset(mp, '#', sizeof(mp));
    memset(vis, false, sizeof(vis));
    for (int i = 1; i <= n; i++) cin >> &mp[i][1];
    int flag = 0;
    int 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') {
          mp[i][j + 1] = '#';
          mp[i][j - 1] = '#';
          mp[i - 1][j] = '#';
          mp[i + 1][j] = '#';
        } 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 {
      queue<node> Q;
      node q;
      q.x = n;
      q.y = m;
      vis[n][m] = true;
      if (mp[n][m] == '.') Q.push(q);
      while (!Q.empty()) {
        node a = Q.front();
        vis[a.x][a.y] = true;
        if (mp[a.x][a.y] == 'G') num--;
        Q.pop();
        node hd;
        for (int i = 0; i < 4; i++) {
          hd.x = a.x + dir[i][0];
          hd.y = a.y + dir[i][1];
          if ((mp[hd.x][hd.y] == '.' || mp[hd.x][hd.y] == 'G') &&
              !vis[hd.x][hd.y])
            Q.push(hd);
        }
        if (num == 0) break;
      }
      if (num)
        cout << "No" << endl;
      else
        cout << "Yes" << endl;
    }
  }
}
