#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
typedef struct sol {
  ll val;
  ll h;
} sol;
typedef struct elem {
  int x1, x2, y1, y2;
  bool operator==(const elem& t) const {
    return (this->x1 == t.x1 && this->x2 == t.x2 && this->y1 == t.y1 &&
            this->y2 == t.y2);
  }
} elem;
class ElemHash {
 public:
  size_t operator()(const elem& t) const { return t.x1 + t.x2 + t.y1 + t.y2; }
};
bool sort_sec(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.second < b.second);
}
bool comp_s(const vector<char>& s1, const vector<char>& s2) {
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] == s2[i])
      continue;
    else if (s1[i] < s2[i])
      return true;
    else
      return false;
  }
  return false;
}
typedef struct node {
  char c;
  node* l;
  node* r;
} node;
int main() {
  int t0;
  scanf("%d\n", &t0);
  for (int itr = 0; itr < t0; ++itr) {
    int n, m;
    scanf("%d %d\n", &n, &m);
    vector<string> mp(n);
    for (int i = 0; i < n; ++i) {
      getline(cin, mp[i]);
    }
    vector<pair<int, int>> g;
    bool ans = true;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (mp[i][j] == 'G') g.push_back({i, j});
        if (mp[i][j] != 'B') continue;
        int i1 = i - 1, j1 = j;
        if (i1 >= 0) {
          if (mp[i1][j1] == '.')
            mp[i1][j1] = '#';
          else if (mp[i1][j1] == 'G') {
            ans = false;
            break;
          }
        }
        i1 = i + 1;
        if (i1 < n) {
          if (mp[i1][j1] == '.')
            mp[i1][j1] = '#';
          else if (mp[i1][j1] == 'G') {
            ans = false;
            break;
          }
        }
        i1 = i, j1 = j - 1;
        if (j1 >= 0) {
          if (mp[i1][j1] == '.')
            mp[i1][j1] = '#';
          else if (mp[i1][j1] == 'G') {
            ans = false;
            break;
          }
        }
        j1 = j + 1;
        if (j1 < m) {
          if (mp[i1][j1] == '.')
            mp[i1][j1] = '#';
          else if (mp[i1][j1] == 'G') {
            ans = false;
            break;
          }
        }
      }
      if (!ans) break;
    }
    if (!ans) {
      cout << "No" << endl;
      continue;
    }
    queue<pair<int, int>> f;
    vector<vector<int>> visited(n, vector<int>(m, 0));
    for (pair<int, int> pos : g) {
      f.push(pos);
      visited[pos.first][pos.second] = 1;
      while (f.size() > 0) {
        pair<int, int> next = f.front();
        f.pop();
        int i = next.first, j = next.second;
        if (i == n - 1 && j == m - 1) break;
        int i1 = i - 1, j1 = j;
        if (i1 >= 0 && (!visited[i1][j1]) &&
            (mp[i1][j1] == '.' || mp[i1][j1] == 'G')) {
          f.push({i1, j1});
          visited[i1][j1] = 1;
        }
        i1 = i + 1;
        if (i1 < n && (!visited[i1][j1]) &&
            (mp[i1][j1] == '.' || mp[i1][j1] == 'G')) {
          f.push({i1, j1});
          visited[i1][j1] = 1;
        }
        i1 = i, j1 = j - 1;
        if (j1 >= 0 && (!visited[i1][j1]) &&
            (mp[i1][j1] == '.' || mp[i1][j1] == 'G')) {
          f.push({i1, j1});
          visited[i1][j1] = 1;
        }
        j1 = j + 1;
        if (j1 < m && (!visited[i1][j1]) &&
            (mp[i1][j1] == '.' || mp[i1][j1] == 'G')) {
          f.push({i1, j1});
          visited[i1][j1] = 1;
        }
        if (f.size() == 0) {
          ans = false;
          break;
        }
      }
      if (!ans) break;
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          visited[i][j] = 0;
        }
      }
    }
    visited.clear();
    if (ans)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
