#include <bits/stdc++.h>
using namespace std;
int mas[51][51], mas1[51][51];
int n, m;
int i, j;
int i1;
int k, l;
string s;
int p;
int x, y;
int num;
deque<pair<int, int> > q;
int main() {
  cin >> k;
  for (i1 = 0; i1 < k; i1++) {
    cin >> n >> m;
    num = 0;
    for (i = 0; i <= n + 1; i++)
      for (j = 0; j <= m + 1; j++) mas[i][j] = 1;
    for (i = 1; i <= n; i++) {
      cin >> s;
      for (j = 1; j <= m; j++) {
        mas1[i][j] = 0;
        if (s[j - 1] == '.') {
          mas[i][j] = 0;
        } else if (s[j - 1] == '#') {
          mas[i][j] = 1;
        } else if (s[j - 1] == 'G') {
          num++;
          mas[i][j] = 2;
        } else if (s[j - 1] == 'B') {
          mas[i][j] = 3;
        }
      }
    }
    p = 1;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        if (mas[i][j] == 3) {
          if ((mas[i][j + 1] == 2) || (mas[i][j - 1] == 2) ||
              (mas[i + 1][j] == 2) || (mas[i - 1][j] == 2)) {
            p = 0;
          }
          mas[i][j + 1] = 1;
          mas[i][j - 1] = 1;
          mas[i - 1][j] = 1;
          mas[i + 1][j] = 1;
          mas[i][j] = 1;
        }
      }
    if (mas[n][m] == 1)
      if (num > 0) {
        cout << "No";
        cout << endl;
        continue;
      }
    if (p == 0) {
      cout << "No";
      cout << endl;
      continue;
    }
    q.push_back(make_pair(n, m));
    mas1[n][m] = 1;
    while (q.size()) {
      pair<int, int> t;
      t = q[0];
      x = t.first;
      y = t.second;
      q.pop_front();
      if (mas[x][y + 1] != 1)
        if (mas1[x][y + 1] == 0) {
          mas1[x][y + 1] = 1;
          q.push_back(make_pair(x, y + 1));
        }
      if (mas[x][y - 1] != 1)
        if (mas1[x][y - 1] == 0) {
          mas1[x][y - 1] = 1;
          q.push_back(make_pair(x, y - 1));
        }
      if (mas[x + 1][y] != 1)
        if (mas1[x + 1][y] == 0) {
          mas1[x + 1][y] = 1;
          q.push_back(make_pair(x + 1, y));
        }
      if (mas[x - 1][y] != 1)
        if (mas1[x - 1][y] == 0) {
          mas1[x - 1][y] = 1;
          q.push_back(make_pair(x - 1, y));
        }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (mas[i][j] == 2)
          if (mas1[i][j] == 0) {
            p = 0;
          }
      }
    }
    if (p) {
      cout << "Yes" << endl;
    } else
      cout << "No" << endl;
  }
}
