#include <bits/stdc++.h>
long long dd, hh, n, i, j, h, k, t, d, m, test, dx[4] = {-1, 0, 1, 0},
                                                dy[4] = {0, 1, 0, -1};
bool kt[100][100];
char a[100][100];
using namespace std;
void xl(int u, int v) {
  if (u < 1 || u > n || v < 1 || v > m || kt[u][v] == 1 || a[u][v] == '#' ||
      a[u][v] == 'B')
    return;
  kt[u][v] = 1;
  if (a[u][v] == 'B') {
    dd = -1232321312;
    return;
  }
  if (a[u][v] == 'G') {
    dd++;
  }
  for (int i = 0; i < 4; i++) xl(u + dx[i], v + dy[i]);
}
int main() {
  cin >> test;
  for (hh = 1; hh <= test; hh++) {
    cin >> n >> m;
    d = 0;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) cin >> a[i][j], kt[i][j] = 0;
    ;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        if (a[i][j] == 'G') d++;
        ;
        if (a[i - 1][j] == 'B' || (i < n && a[i + 1][j] == 'B') ||
            (j < m && a[i][j + 1] == 'B') || a[i][j - 1] == 'B')
          if (a[i][j] == 'G') {
            d = -12312312;
          } else
            a[i][j] = '#';
      }
    if (d < 0)
      cout << "No" << endl;
    else {
      dd = 0;
      for (i = 1; i <= n; i++)
        for (j = 1; j <= m; j++)
          if (a[i][j] == '.' || a[i][j] == 'G') {
            xl(i, j);
            if (dd != 0 || kt[n][m] == 1) i += n, j += m;
          }
      if (dd < 0 || a[n][m] == 'B')
        cout << "No" << endl;
      else if (d == 0)
        cout << "Yes" << endl;
      else if (a[n][m] == '#')
        cout << "No" << endl;
      else if (dd == d && kt[n][m] == 1)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
  }
}
