#include <bits/stdc++.h>
using namespace std;
void test() {
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  bool flag = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        if (i < n - 1 and s[i + 1][j] == 'G') flag = false;
        if (j < m - 1 and s[i][j + 1] == 'G') flag = false;
        if (j > 0 and s[i][j - 1] == 'G') flag = false;
        if (i > 0 and s[i - 1][j] == 'G') flag = false;
      }
    }
  }
  if (!flag) {
    cout << "No\n";
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'B') {
        if (i < n - 1 and s[i + 1][j] != 'B') s[i + 1][j] = '#';
        if (j < m - 1 and s[i][j + 1] != 'B') s[i][j + 1] = '#';
        if (j > 0 and s[i][j - 1] != 'B') s[i][j - 1] = '#';
        if (i > 0 and s[i - 1][j] != 'B') s[i - 1][j] = '#';
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] == 'G') cnt++;
  if (cnt == 0) {
    cout << "Yes\n";
    return;
  } else if (cnt != 0 and s[n - 1][m - 1] == '#') {
    cout << "No\n";
    return;
  }
  queue<pair<int, int> > q;
  bool vis[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) vis[i][j] = false;
  vis[n - 1][m - 1] = true;
  q.push({n - 1, m - 1});
  while (!q.empty()) {
    pair<int, int> x = q.front();
    q.pop();
    if (x.first < n - 1 and (!vis[x.first + 1][x.second]) and
        s[x.first + 1][x.second] != '#') {
      vis[x.first + 1][x.second] = true;
      q.push({x.first + 1, x.second});
    }
    if (x.first > 0 and (!vis[x.first - 1][x.second]) and
        s[x.first - 1][x.second] != '#') {
      vis[x.first - 1][x.second] = true;
      q.push({x.first - 1, x.second});
    }
    if (x.second < m - 1 and (!vis[x.first][x.second + 1]) and
        s[x.first][x.second + 1] != '#') {
      vis[x.first][x.second + 1] = true;
      q.push({x.first, x.second + 1});
    }
    if (x.second > 0 and (!vis[x.first][x.second - 1]) and
        s[x.first][x.second - 1] != '#') {
      vis[x.first][x.second - 1] = true;
      q.push({x.first, x.second - 1});
    }
  }
  flag = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'G' and (!vis[i][j])) {
        flag = false;
      }
    }
  }
  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";
}
int main() {
  int tests = 1;
  cin >> tests;
  while (tests--) {
    test();
  }
}
