#include <bits/stdc++.h>
using namespace std;
struct node {
  long long nod, d;
  node(long long a, long long b) {
    nod = a;
    d = b;
  }
  bool operator<(const node &p) const { return p.d < d; }
};
long long Set(long long n, long long pos) { return n = n | (1LL << pos); }
long long reset(long long n, long long pos) { return n = n & ~(1LL << pos); }
bool check(long long n, long long pos) { return (bool)(n & (1LL << pos)); }
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
int main() {
  long long tes;
  scanf("%lld", &tes);
  for (long long cas = 1; cas <= tes; cas++) {
    long long n, m;
    scanf("%lld", &n);
    scanf("%lld", &m);
    string matt[n + 4];
    for (long long i = 0; i < n; i++) {
      cin >> matt[i];
    }
    long long b_cnt = 0;
    long long g_cnt = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (matt[i][j] == 'G')
          g_cnt++;
        else if (matt[i][j] == 'B')
          b_cnt++;
      }
    }
    if (g_cnt == 0) {
      printf("Yes\n");
      continue;
    }
    bool vis[n + 2][m + 2];
    int fx[] = {1, -1, 0, 0};
    int fy[] = {0, 0, 1, -1};
    deque<pair<long long, long long> > q;
    memset(vis, 0, sizeof vis);
    vis[n - 1][m - 1] = 1;
    q.push_back(pair<long long, long long>(n - 1, m - 1));
    while (!q.empty()) {
      pair<long long, long long> top = q.front();
      q.pop_front();
      for (int k = 0; k < 4; k++) {
        long long tx = top.first + fx[k];
        long long ty = top.second + fy[k];
        if (tx >= 0 and tx < n and ty >= 0 and ty < m) {
          if (matt[tx][ty] != '#' and vis[tx][ty] == 0) {
            vis[tx][ty] = 1;
            q.push_back(pair<long long, long long>(tx, ty));
          }
        }
      }
    }
    bool f = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (matt[i][j] == 'G' && vis[i][j] == 0) {
          f = 1;
        }
      }
    }
    if (f) {
      printf("No\n");
      continue;
    }
    if (b_cnt == 0) {
      printf("Yes\n");
      continue;
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (matt[i][j] != 'B') continue;
        for (int k = 0; k < 4; k++) {
          int tx = i + fx[k];
          int ty = j + fy[k];
          if (tx >= 0 and tx < n and ty >= 0 and ty < m) {
            if (matt[tx][ty] == 'G' || (tx == n - 1 && ty == m - 1)) {
              f = 1;
            }
          }
        }
      }
    }
    if (f) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}
