#include <bits/stdc++.h>
using namespace std;
bool dfs(vector<string>& arr, int x, int y) {
  int n = arr.size();
  int m = arr[0].size();
  if (x >= n || y >= m) {
    return false;
  }
  if (x == n - 1 && y == m - 1) {
    if (arr[x][y] == '.') {
      return true;
    }
    return false;
  }
  if (arr[x][y] == '#') {
    return false;
  }
  bool ans = false;
  ans = ans | dfs(arr, x + 1, y) | dfs(arr, x, y + 1);
  return ans;
}
bool check(vector<string>& arr) {
  int n = arr.size();
  int m = arr[0].size();
  bool ans = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'B') {
        if (dfs(arr, i, j)) {
          ans = false;
          break;
        }
      }
      if (arr[i][j] == 'G') {
        if (!dfs(arr, i, j)) {
          ans = false;
          break;
        }
      }
    }
  }
  return ans;
}
bool find(vector<string>& arr, int x, int y) {
  int n = arr.size();
  int m = arr[0].size();
  bool ans = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '.') {
        arr[i][j] = '#';
        ans = ans | check(arr);
        if (ans) {
          return true;
        }
        ans = ans | find(arr, i, j);
        if (ans) {
          return true;
        }
        arr[i][j] = '.';
      }
    }
  }
  ans = ans | check(arr);
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<string> arr(n);
    for (int i = 0; i < n; i++) {
      arr[i].resize(m);
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
      }
    }
    bool ans = find(arr, 0, 0);
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
