#include <bits/stdc++.h>
using namespace std;
char G[55][55];
long long vis[55][55];
long long direX[] = {1, 0, -1, 0};
long long direY[] = {0, 1, 0, -1};
long long n, m;
void solve() {
  memset(vis, 0, sizeof(vis));
  cin >> n >> m;
  vector<pair<long long, long long>> good, bad;
  for (int i = 1; i <= n; i++) {
    string mm;
    cin >> mm;
    for (int j = 1; j <= m; j++) {
      G[i][j] = mm[j - 1];
      if (G[i][j] == 'G') good.push_back({i, j});
      if (G[i][j] == 'B') bad.push_back({i, j});
    }
  }
  if (bad.size() == 0 || good.size() == 0) {
    cout << "Yes" << endl;
    return;
  }
  long long flag1 = 0;
  for (int i = 0; i < bad.size(); i++) {
    for (int j = 0; j < 4; j++) {
      if (1 <= bad[i].first + direY[j] && bad[i].first + direY[j] <= n &&
          1 <= bad[i].second + direX[j] && bad[i].second + direX[j] <= m) {
        if (G[bad[i].first + direY[j]][bad[i].second + direX[j]] == 'G') {
          flag1 = 1;
          break;
        }
      }
    }
  }
  if (flag1) {
    cout << "No" << endl;
    return;
  }
  for (int i = 0; i < bad.size(); i++) {
    for (int j = 0; j < 4; j++) {
      if (1 <= bad[i].first + direY[j] && bad[i].first + direY[j] <= n &&
          1 <= bad[i].second + direX[j] && bad[i].second + direX[j] <= m) {
        if (G[bad[i].first + direY[j]][bad[i].second + direX[j]] != 'B') {
          G[bad[i].first + direY[j]][bad[i].second + direX[j]] = '#';
        }
      }
    }
  }
  queue<pair<long long, long long>> Q;
  Q.push({n, m});
  while (!Q.empty()) {
    pair<long long, long long> pos = Q.front();
    Q.pop();
    if (vis[pos.first][pos.second] == 1)
      continue;
    else if (G[pos.first][pos.second] == '#')
      continue;
    else
      vis[pos.first][pos.second] = 1;
    for (int i = 0; i < 4; i++) {
      if (1 <= pos.first + direY[i] && pos.first + direY[i] <= n &&
          1 <= pos.second + direX[i] && pos.second + direX[i] <= m) {
        Q.push({pos.first + direY[i], pos.second + direX[i]});
      }
    }
  }
  long long flag2 = 0;
  for (int i = 0; i < good.size(); i++) {
    if (vis[good[i].first][good[i].second] == 0) {
      flag2 = 1;
      break;
    }
  }
  if (flag2)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
