#include <bits/stdc++.h>
using namespace std;
string digit = "0123456789";
string small = "abcdefghijklmnopqrstuvwxyz";
string capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int a[50][50];
bool isvalid(int aa, int b, int n, int m) {
  if ((aa >= 0 && aa < n) && (b >= 0 && b < m))
    return true;
  else
    return false;
}
void dfs(int nn, int mm, int n, int m) {
  a[nn][mm] = 2;
  for (int i = 0; i < 4; i++) {
    int x = dx4[i] + nn;
    int y = dy4[i] + mm;
    if (isvalid(x, y, n, m) && a[x][y] == 0) {
      dfs(x, y, n, m);
    }
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  char arr[n][m];
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(m); j++) cin >> arr[i][j];
  int cntG = 0;
  bool flag = true;
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(m); j++) {
      if (arr[i][j] == 'G') cntG++;
      if (arr[i][j] == 'B') {
        for (int k = 0; k < 4; k++) {
          if (isvalid(i + dx4[k], j + dy4[k], n, m) &&
              arr[dx4[k]][dy4[k]] == 'G')
            flag = false;
        }
      }
    }
  if (cntG == 0) {
    cout << "Yes"
         << "\n";
    return;
  } else if (!flag) {
    cout << "No"
         << "\n";
    return;
  } else {
    for (int i = (int)(0); i < (int)(n); i++) {
      for (int j = (int)(0); j < (int)(m); j++) {
        if (arr[i][j] == 'B') {
          for (int k = (int)(0); k < (int)(4); k++) {
            int c = dx4[k] + i;
            int d = dy4[k] + j;
            if (isvalid(c, d, n, m) && arr[c][d] == '.') arr[c][d] = '#';
          }
        }
      }
    }
    if (arr[n - 1][m - 1] == '#') {
      cout << "No"
           << "\n";
      return;
    }
    for (int i = (int)(0); i < (int)(n); i++) {
      for (int j = (int)(0); j < (int)(m); j++) {
        if (arr[i][j] == '.')
          a[i][j] = 0;
        else
          a[i][j] = 1;
      }
    }
    dfs(n - 1, m - 1, n, m);
    bool f = true;
    for (int i = (int)(0); i < (int)(n); i++) {
      for (int j = (int)(0); j < (int)(m); j++) {
        bool ff = false;
        if (arr[i][j] == 'G') {
          for (int kk = 0; kk < 4; kk++) {
            int xx = dx4[kk] + i;
            int yy = dy4[kk] + j;
            if (isvalid(xx, yy, n, m) && (a[xx][yy] == 2 || a[xx][yy] == 'G'))
              ff = true;
          }
          f = ff;
        }
      }
    }
    if (f) {
      cout << "Yes"
           << "\n";
      return;
    } else {
      cout << "No"
           << "\n";
      return;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
