#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int> v1;
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int i = 2; i * i <= 1000000; i++)
    if (prime[i])
      for (int j = i * i; j <= 1000000; j += i) prime[j] = false;
  prime[0] = prime[1] = false;
}
char a[600][600];
int visited[600][600];
int n, m;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool check(int i, int j) {
  if (i >= 0 && i < n && j >= 0 && j < m) {
    return true;
  } else {
    return false;
  }
}
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= m || visited[i][j] == 1) {
    return;
  }
  visited[i][j] = 1;
  dfs(i - 1, j);
  dfs(i + 1, j);
  dfs(i, j + 1);
  dfs(i, j - 1);
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    memset(visited, -1, sizeof(visited));
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    int cnt1 = 2;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          if (check(i + 1, j)) {
            if (a[i + 1][j] == 'G') {
              cnt1 = 5;
              break;
            } else if (a[i + 1][j] == '.') {
              a[i + 1][j] = '#';
            }
          }
          if (check(i - 1, j)) {
            if (a[i - 1][j] == 'G') {
              cnt1 = 5;
              break;
            } else if (a[i - 1][j] == '.') {
              a[i - 1][j] = '#';
            }
          }
          if (check(i, j + 1)) {
            if (a[i][j + 1] == 'G') {
              cnt1 = 5;
              break;
            } else if (a[i + 1][j] == '.') {
              a[i][j + 1] = '#';
            }
          }
          if (check(i, j - 1)) {
            if (a[i][j - 1] == 'G') {
              cnt1 = 5;
              break;
            } else if (a[i][j - 1] == '.') {
              a[i][j - 1] = '#';
            }
          }
        }
      }
    }
    if (cnt1 == 5) {
      cout << "No" << endl;
    } else {
      dfs(n - 1, m - 1);
      int papa = 2;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (a[i][j] == 'G') {
            if (a[n - 1][m - 1] == '#') {
              papa = 11;
              break;
            }
            if (visited[i][j] == -1) {
              papa = 11;
              break;
            }
          }
        }
      }
      if (papa == 11) {
        cout << "No" << endl;
      } else {
        cout << "Yes\n";
      }
    }
  }
  return 0;
}
