#include <bits/stdc++.h>
using namespace std;
int c[100][100];
int coun = 0;
void rec(vector<char> a[], int i, int j, int n, int m) {
  char r = 'G';
  if (a[i][j] == r) coun++;
  c[i][j] = 1;
  if (i > 0 && c[i - 1][j] == 0 && (a[i - 1][j] != '#')) rec(a, i - 1, j, n, m);
  if (i < n - 1 && c[i + 1][j] == 0 && a[i + 1][j] != '#')
    rec(a, i + 1, j, n, m);
  if (j > 0 && c[i][j - 1] == 0 && a[i][j - 1] != '#') rec(a, i, j - 1, n, m);
  if (j < m - 1 && c[i][j + 1] == 0 && a[i][j + 1] != '#')
    rec(a, i, j + 1, n, m);
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    char r = 'G';
    int n, m, cg = 0, cb = 0, f = 0, g = 0;
    cin >> n >> m;
    vector<char> a[n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        char k;
        cin >> k;
        a[i].push_back(k);
        if (k == 'B')
          cb++;
        else if (k == 'G')
          cg++;
        c[i][j] = 0;
      }
    }
    if ((cb == 0 && cg == 0) || cg == 0)
      cout << "Yes" << endl;
    else {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < a[i].size(); j++) {
          if (a[i][j] == 'B') {
            if (i > 0) {
              if (a[i - 1][j] == r)
                f = 1;
              else if (a[i - 1][j] != 'B')
                a[i - 1][j] = '#';
            }
            if (i < n - 1) {
              if (a[i + 1][j] == r)
                f = 1;
              else if (a[i + 1][j] != 'B')
                a[i + 1][j] = '#';
            }
            if (j > 0) {
              if (a[i][j - 1] == r)
                f = 1;
              else if (a[i][j - 1] != 'B')
                a[i][j - 1] = '#';
            }
            if (j < m - 1) {
              if (a[i][j + 1] == r)
                f = 1;
              else if (a[i][j + 1] != 'B')
                a[i][j + 1] = '#';
            }
            if (f == 1) break;
          }
        }
        if (f == 1) break;
      }
      if (f == 1)
        cout << "No" << endl;
      else {
        if (a[n - 1][m - 1] == '#')
          cout << "No" << endl;
        else {
          for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) c[i][j] = 0;
          }
          coun = 0;
          c[n - 1][m - 1] = 1;
          rec(a, n - 1, m - 1, n, m);
          if (coun == cg)
            cout << "Yes" << endl;
          else
            cout << "No" << endl;
        }
      }
    }
  }
}
