#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
char v[52][52];
int a, b;
bool dfs(int x, int y) {
  if (x < 0 || x == a || y < 0 || y == b || v[x][y] == '#') return false;
  if (x == a - 1 && y == b - 1) return true;
  if (dfs(x + 1, y))
    return true;
  else if (dfs(x - 1, y))
    return true;
  else if (dfs(x, y + 1))
    return true;
  else if (dfs(x, y - 1))
    return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    for (int i = 0; i < a; ++i) {
      for (int y = 0; y < b; y++) {
        cin >> v[i][y];
      }
    }
    bool isfound = false;
    for (int i = 0; i < a; ++i) {
      for (int y = 0; y < b; y++) {
        if (v[i][y] == 'B') {
          if (i - 1 >= 0) {
            if (v[i - 1][y] == 'G') {
              isfound = true;
              break;
            } else
              v[i - 1][y] = '#';
          }
          if (i + 1 < a) {
            if (v[i + 1][y] == 'G') {
              isfound = true;
              break;
            } else
              v[i + 1][y] = '#';
          }
          if (y - 1 >= 0) {
            if (v[i][y - 1] == 'G') {
              isfound = true;
              break;
            } else
              v[i][y - 1] = '#';
          }
          if (y + 1 < b) {
            if (v[i][y + 1] == 'G') {
              isfound = true;
              break;
            } else
              v[i][y + 1] = '#';
          }
        }
      }
      if (isfound) break;
    }
    if (isfound) {
      cout << "No\n";
    } else {
      isfound = false;
      for (int i = 0; i < a; ++i) {
        for (int y = 0; y < b; y++) {
          if (v[i][y] == 'G') {
            if (!dfs(i, y)) {
              isfound = true;
              break;
            }
          }
        }
        if (isfound) break;
      }
      if (isfound) {
        cout << "No\n";
      } else
        cout << "Yes\n";
    }
  }
  return 0;
}
