#include <bits/stdc++.h>
using namespace std;
template <class T>
void mini(T& a, T b) {
  a = min(a, b);
}
template <class T>
void maxi(T& a, T b) {
  a = max(a, b);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  return out << a.first << " " << a.second;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, set<T> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T>
void out(T a) {
  cout << a << endl;
}
void out() { cout << "OK" << endl; }
const int N = 55;
const int inf = 1e9;
int a[N][N];
queue<pair<int, int> > q;
bool used[N][N];
int dist[N][N];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void Solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      a[i][j] = 0;
      used[i][j] = 0;
      dist[i][j] = inf;
    }
  }
  while (!q.empty()) q.pop();
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == 'G') {
        a[i][j] = 2;
        cnt++;
      }
      if (c == '.') a[i][j] = 1;
      if (c == 'B') a[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != -1) continue;
      for (int k = 0; k <= 3; k++) {
        int x = i + dx[k];
        int y = j + dy[k];
        if (a[x][y] == 2) {
          cout << "No\n";
          return;
        }
        if (a[x][y] != -1) {
          a[x][y] = 0;
        }
      }
    }
  }
  int kek = 0;
  if (a[n][m]) {
    q.push({n, m});
    dist[n][m] = 0;
    while (!q.empty()) {
      pair<int, int> cur = q.front();
      int i = cur.first;
      int j = cur.second;
      q.pop();
      if (used[i][j]) continue;
      used[i][j] = 1;
      if (a[i][j] == 2) kek++;
      for (int k = 0; k <= 3; k++) {
        int x = i + dx[k];
        int y = j + dy[k];
        if (a[x][y] <= 0) continue;
        if (dist[x][y] > dist[i][j] + 1) {
          dist[x][y] = dist[i][j] + 1;
          q.push({x, y});
        }
      }
    }
  }
  if (kek != cnt) {
    cout << "No\n";
  } else
    cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    Solve();
  }
  return 0;
}
