#include <bits/stdc++.h>
using namespace std;
long long t, n, m, b, g, vis[59][59], f;
string s[509];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    b = g = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == 'B')
          b++;
        else if (s[i][j] == 'G')
          g++;
      }
    }
    memset(vis, 0, sizeof vis);
    if (!g)
      cout << "Yes\n";
    else {
      f = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (s[i][j] == 'B') {
            if (i - 1 >= 0 && s[i - 1][j] == '.') s[i - 1][j] = '#';
            if (i - 1 >= 0 && s[i - 1][j] == 'G') f = 1;
            if (j - 1 >= 0 && s[i][j - 1] == '.') s[i][j - 1] = '#';
            if (j - 1 >= 0 && s[i][j - 1] == 'G') f = 1;
            if (i + 1 < n && s[i + 1][j] == '.') s[i + 1][j] = '#';
            if (i + 1 < n && s[i + 1][j] == 'G') f = 1;
            if (j + 1 < m && s[i][j + 1] == '.') s[i][j + 1] = '#';
            if (j + 1 < m && s[i][j + 1] == 'G') f = 1;
          }
        }
      }
      queue<pair<int, int>> q;
      q.push({n - 1, m - 1});
      vis[n - 1][m - 1] = 1;
      while (q.size()) {
        pair<int, int> x = q.front();
        q.pop();
        if (x.first - 1 >= 0 &&
            (s[x.first - 1][x.second] == '.' ||
             s[x.first - 1][x.second] == 'G') &&
            !vis[x.first - 1][x.second])
          vis[x.first - 1][x.second] = 1, q.push({x.first - 1, x.second});
        if (x.second - 1 >= 0 &&
            (s[x.first][x.second - 1] == '.' ||
             s[x.first][x.second - 1] == 'G') &&
            !vis[x.first][x.second - 1])
          vis[x.first][x.second - 1] = 1, q.push({x.first, x.second - 1});
        if (x.first + 1 < n &&
            (s[x.first + 1][x.second] == '.' ||
             s[x.first + 1][x.second] == 'G') &&
            !vis[x.first + 1][x.second])
          vis[x.first + 1][x.second] = 1, q.push({x.first + 1, x.second});
        if (x.second + 1 < m &&
            (s[x.first][x.second + 1] == '.' ||
             s[x.first][x.second + 1] == 'G') &&
            !vis[x.first][x.second + 1])
          vis[x.first][x.second + 1] = 1, q.push({x.first, x.second + 1});
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (s[i][j] == 'G' && !vis[i][j]) f = 1;
        }
      }
      if (f || s[n - 1][m - 1] == '#')
        cout << "No\n";
      else
        cout << "Yes\n";
    }
  }
}
