#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, n, m, i, j, flag, g;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<vector<char> > v(n, vector<char>(m));
    g = 0;
    for (int p = 0; p < n; p++)
      for (int q = 0; q < m; q++) {
        cin >> v[p][q];
        if (v[p][q] == 'G') g++;
      }
    flag = 1;
    for (int p = 0; p < n; p++) {
      for (int q = 0; q < m; q++) {
        if (v[p][q] == 'B') {
          if (p + 1 < n) {
            if (v[p + 1][q] == 'G') {
              flag = 0;
              break;
            } else if (v[p + 1][q] == '.')
              v[p + 1][q] = '#';
          }
          if (q + 1 < m) {
            if (v[p][q + 1] == 'G') {
              flag = 0;
              break;
            } else if (v[p][q + 1] == '.')
              v[p][q + 1] = '#';
          }
        }
      }
      if (!flag) break;
    }
    if (!flag || (v[n - 1][m - 1] == '#' && g))
      cout << "No\n";
    else {
      if (v[n - 1][m - 1] == '#' && g == 0)
        cout << "Yes\n";
      else {
        queue<pair<int, int> > q;
        pair<int, int> a;
        q.push(make_pair(n - 1, m - 1));
        while (!q.empty()) {
          a = q.front();
          if (v[a.first][a.second] == 'G') g--;
          q.pop();
          if (a.first - 1 >= 0) {
            if (v[a.first - 1][a.second] == 'B') {
              flag = 0;
              break;
            } else if (v[a.first - 1][a.second] == 'G' ||
                       v[a.first - 1][a.second] == '.')
              q.push(make_pair(a.first - 1, a.second));
          }
          if (a.second - 1 >= 0) {
            if (v[a.first][a.second - 1] == 'B') {
              flag = 0;
              break;
            } else if (v[a.first][a.second - 1] == 'G' ||
                       v[a.first][a.second - 1] == '.')
              q.push(make_pair(a.first, a.second - 1));
          }
        }
        if (!flag || g)
          cout << "No\n";
        else
          cout << "Yes\n";
      }
    }
  }
  return 0;
}
