#include <bits/stdc++.h>
using namespace std;
int r, c;
bool visited[55][55];
char mat[55][55];
int row[4] = {1, -1, 0, 0};
int col[4] = {0, 0, 1, -1};
vector<pair<int, int> > goodPeople;
bool valid(int x, int y) {
  if (x <= r && x >= 1 && y <= c && y >= 1) return true;
  return false;
}
bool ans1 = false;
bool ans2;
queue<pair<int, int> > q;
void bfs() {
  if (q.empty()) return;
  pair<int, int> lol = q.front();
  visited[lol.first][lol.second] = true;
  while (!q.empty()) {
    pair<int, int> peyar = q.front();
    int source1 = peyar.first;
    int source2 = peyar.second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int ro = source1 + row[i];
      int co = source2 + col[i];
      if (valid(ro, co)) {
        if (!visited[ro][co] && mat[ro][co] != '#' && mat[ro][co] != 'B') {
          if (mat[ro][co] == 'G') ans1 = true;
          mat[ro][co] = '#';
          visited[ro][co] = true;
        }
      }
    }
  }
}
void bfsReturns(int src1, int src2) {
  queue<pair<int, int> > qqq;
  visited[src1][src2] = true;
  qqq.push(make_pair(src1, src2));
  while (!qqq.empty()) {
    pair<int, int> peyar = qqq.front();
    int source1 = peyar.first;
    int source2 = peyar.second;
    qqq.pop();
    for (int i = 0; i < 4; i++) {
      int ro = source1 + row[i];
      int co = source2 + col[i];
      if (ro == r && co == c) ans2 = true;
      if (valid(ro, co)) {
        if (!visited[ro][co] && mat[ro][co] != '#') {
          qqq.push(make_pair(ro, co));
          visited[ro][co] = true;
        }
      }
    }
  }
}
void visSet() {
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) {
      visited[i][j] = false;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> r >> c;
    bool good = false;
    for (int i = 1; i <= r; i++) {
      for (int j = 1; j <= c; j++) {
        cin >> mat[i][j];
        if (mat[i][j] == 'G') {
          good = true;
          goodPeople.push_back(make_pair(i, j));
        }
        if (mat[i][j] == 'B') q.push(make_pair(i, j));
      }
    }
    if (mat[r - 1][c] == 'B' || mat[r][c - 1] == 'B') {
      cout << "No" << endl;
      ans1 = false;
      visSet();
      goodPeople.clear();
      continue;
    }
    if (!good) {
      cout << "Yes" << endl;
      ans1 = false;
      visSet();
      goodPeople.clear();
      continue;
    }
    bfs();
    if (ans1) {
      cout << "No" << endl;
      ans1 = false;
      visSet();
      goodPeople.clear();
      continue;
    }
    visSet();
    for (int i = 0; i < goodPeople.size(); i++) {
      ans2 = false;
      bfsReturns(goodPeople[i].first, goodPeople[i].second);
      if (!ans2) break;
      visSet();
    }
    if (!ans2) {
      cout << "Nowww" << endl;
      ans1 = false;
      visSet();
      goodPeople.clear();
      continue;
    }
    cout << "Yes" << endl;
    ans1 = false;
    visSet();
    goodPeople.clear();
  }
}
