#include <bits/stdc++.h>
using namespace std;
int dir[4][2]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int m;
    cin >> m;
    char a[n][m];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          for (int k = 0; k < 4; k++) {
            int x = i + dir[k][0];
            int y = j + dir[k][1];
            if ((x > -1 && y > -1 && x < n && y < m) && a[x][y] == '.') {
              a[x][y] = '#';
            }
          }
        }
      }
    }
    queue<pair<int, int> > q;
    int v[n + 2][m + 2];
    for (int i = 0; i < n + 2; ++i) {
      for (int j = 0; j < m + 2; j++) {
        v[i][j] = 0;
      }
    }
    if (a[n - 1][m - 1] == '.') {
      q.push({n - 1, m - 1});
      v[n][m] = 1;
    }
    pair<int, int> pp;
    while (!q.empty()) {
      pp = q.front();
      q.pop();
      for (int i = 0; i < 4; i++) {
        int x = pp.first + dir[i][0];
        int y = pp.second + dir[i][1];
        if ((x > -1 && y > -1 && x < n && y < m) && v[x][y] == 0 &&
            a[x][y] != '#') {
          q.push({x, y});
          v[x][y] = 1;
        }
      }
    }
    int g = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; j++) {
        if ((a[i][j] == 'G' && v[i][j] == 0) ||
            (a[i][j] == 'B' && v[i][j] == 1))
          g = 0;
      }
    }
    if (g == 0)
      cout << "no";
    else {
      cout << "yes";
    }
    cout << endl;
  }
  return 0;
}
