#include <bits/stdc++.h>
using namespace std;
long long t, n, m, k, f, c[601], b[200001], us[61][61];
int s1[4] = {1, -1, 0, 0};
int s2[4] = {0, 0, 1, -1};
char a[61][61];
deque<pair<int, int> > q;
int main() {
  cin >> t;
  for (int qwe = 1; qwe <= t; qwe++) {
    cin >> n >> m;
    f = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (a[i][j] == 'B') {
          if (a[i - 1][j] == 'G')
            f = 1;
          else if (a[i - 1][j] != 'G')
            a[i - 1][j] = '#';
          if (a[i + 1][j] == 'G')
            f = 1;
          else if (a[i + 1][j] != 'G')
            a[i + 1][j] = '#';
          if (a[i][j - 1] == 'G')
            f = 1;
          else if (a[i][j - 1] != 'G')
            a[i][j - 1] = '#';
          if (a[i][j + 1] == 'G')
            f = 1;
          else if (a[i][j + 1] != 'G')
            a[i][j + 1] = '#';
        }
    if (f == 1) {
      cout << "No\n";
      continue;
    }
    f = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 'G') {
          for (int er = 1; er <= n; er++)
            for (int rt = 1; rt <= m; rt++) us[er][rt] = 0;
          q.push_back(make_pair(i, j));
          us[i][j] = 1;
          while (!q.empty()) {
            int x = q.front().first;
            int y = q.front().second;
            q.pop_front();
            for (int we = 0; we < 4; we++) {
              int xx = x + s1[we];
              int yy = y + s2[we];
              if (us[xx][yy] == 0 && xx != 0 && yy != 0 && xx != n + 1 &&
                  yy != m + 1 && a[xx][yy] != '#') {
                q.push_back(make_pair(xx, yy));
                us[xx][yy] = 1;
              }
            }
          }
          if (us[n][m] == 0) {
            f = 1;
            break;
          }
        }
      }
      if (f == 1) break;
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) a[i][j] = '.';
    if (f == 1)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
  return 0;
}
