#include <bits/stdc++.h>
using namespace std;
char arr[50][50];
bool visited[50][50];
map<pair<int, int>, bool> covered;
int n, m;
bool dfs(int c_r, int c_c) {
  if (c_r < 0 || c_c < 0 || c_r >= n || c_c >= m || arr[c_r][c_c] == '#' ||
      arr[c_r][c_c] == 'B' || visited[c_r][c_c] == true) {
    return false;
  }
  if (c_r == n - 1 && c_c == m - 1) {
    return true;
  }
  if (arr[c_r][c_c] == 'G') {
    covered[make_pair(c_r, c_c)] = true;
  }
  visited[c_r][c_c] = true;
  bool a = dfs(c_r - 1, c_c);
  if (a) {
    return a;
  }
  a = dfs(c_r + 1, c_c);
  if (a) {
    return a;
  }
  a = dfs(c_r, c_c - 1);
  if (a) {
    return a;
  }
  a = dfs(c_r, c_c + 1);
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<pair<int, int>> good_boy;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
        if (arr[i][j] == 'G') {
          good_boy.push_back(make_pair(i, j));
        }
      }
    }
    bool possible = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (arr[i][j] == 'B') {
          if (i - 1 >= 0) {
            if (arr[i - 1][j] == 'G') {
              possible = false;
              break;
            }
            if (arr[i - 1][j] == '.') {
              arr[i - 1][j] = '#';
            }
          }
          if (i + 1 < n) {
            if (arr[i + 1][j] == 'G') {
              possible = false;
              break;
            }
            if (arr[i + 1][j] == '.') {
              arr[i + 1][j] = '#';
            }
          }
          if (j - 1 >= 0) {
            if (arr[i][j - 1] == 'G') {
              possible = false;
              break;
            }
            if (arr[i][j - 1] == '.') {
              arr[i][j - 1] = '#';
            }
          }
          if (j + 1 < m) {
            if (arr[i][j + 1] == 'G') {
              possible = false;
              break;
            }
            if (arr[i][j + 1] == '.') {
              arr[i][j + 1] = '#';
            }
          }
        }
      }
      if (possible == false) {
        break;
      }
    }
    if (possible == false) {
      cout << "No\n";
      continue;
    }
    for (int i = 0; i < good_boy.size(); i++) {
      int c_r = good_boy.at(i).first, c_c = good_boy.at(i).second;
      if (covered[make_pair(c_r, c_c)] == true) {
        continue;
      }
      memset(visited, 0, sizeof(visited));
      possible = dfs(c_r, c_c);
      if (possible == false) {
        break;
      }
    }
    if (possible == false) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }
  return 0;
}
