#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    char grid[n][m];
    int cG = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> grid[i][j];
        if (grid[i][j] == 'G') cG++;
      }
    }
    int f = 0;
    if (cG != 0) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (grid[i][j] == 'B') {
            int x = 1;
            if (i > 0) {
              if (grid[i - 1][j] == 'G') x = -1;
              if (grid[i - 1][j] == '.') grid[i - 1][j] = '#';
            }
            if (i < n - 1) {
              if (grid[i + 1][j] == 'G') x = -1;
              if (grid[i + 1][j] == '.') grid[i + 1][j] = '#';
            }
            if (j > 0) {
              if (grid[i][j - 1] == 'G') x = -1;
              if (grid[i - 1][j - 1] == '.') grid[i][j - 1] = '#';
            }
            if (j < m - 1) {
              if (grid[i][j + 1] == 'G') x = -1;
              if (grid[i][j + 1] == '.') grid[i][j + 1] = '#';
            }
            if (x == -1) {
              f = 1;
              break;
            }
          }
        }
      }
      if (f == 0) {
        if (grid[n - 1][m - 1] == '#') {
          f = 1;
        } else {
          int c = 0;
          int i = n - 1, j = m - 1;
          stack<int> x, y;
          x.push(i);
          y.push(j);
          while (!x.empty()) {
            i = x.top();
            j = y.top();
            x.pop();
            y.pop();
            if (grid[i][j] == '.') {
              grid[i][j] = '-';
            }
            if (grid[i][j] == 'G') {
              grid[i][j] = '-';
              c++;
            }
            if (i > 0) {
              if (grid[i - 1][j] == '.' || grid[i - 1][j] == 'G') {
                x.push(i - 1);
                y.push(j);
              }
            }
            if (j > 0) {
              if (grid[i][j - 1] == '.' || grid[i][j - 1] == 'G') {
                x.push(i);
                y.push(j - 1);
              }
            }
          }
          if (c != cG) {
            f = 1;
          }
        }
      }
    }
    if (f == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
