#include <bits/stdc++.h>
using namespace std;
long long max3(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
long long min3(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
void change(vector<vector<char>> &a, int i, int j, int n, int m) {
  int y = i, x = j;
  while (x < m) {
    if (a[i][x] == '.' || a[i][x] == '#') {
      a[i][x] = '#';
      break;
    } else
      x++;
  }
  x = j;
  while (x >= 0) {
    if (a[i][x] == '.' || a[i][x] == '#') {
      a[i][x] = '#';
      break;
    } else
      x--;
  }
  while (y < n) {
    if (a[y][j] == '.' || a[y][j] == '#') {
      a[y][j] = '#';
      break;
    } else
      y++;
  }
  y = i;
  while (y >= 0) {
    if (a[y][j] == '.' || a[y][j] == '#') {
      a[y][j] = '#';
      break;
    } else
      y--;
  }
}
void traverse(vector<vector<char>> &a, vector<vector<bool>> &h, int i, int j,
              int n, int m, bool *e) {
  if (i < 0 || i >= n || j < 0 || j >= m || h[i][j] == true) {
    return;
  }
  if (a[i][j] == '#') {
    return;
  }
  if (i == n - 1 && j == m - 1) {
    *e = true;
    return;
  }
  if (i + 1 < n && a[min(n - 1, i + 1)][j] != '#') {
    h[i][j] = true;
    traverse(a, h, i + 1, j, n, m, e);
  }
  if (j + 1 < m && a[i][min(m - 1, j + 1)] != '#') {
    h[i][j] = true;
    traverse(a, h, i, j + 1, n, m, e);
  }
  if (i - 1 >= 0 && a[i][max(0, j - 1)] != '#') {
    h[i][j] = true;
    traverse(a, h, i - 1, j, n, m, e);
  }
  if (j - 1 >= 0 && a[i][max(0, j - 1)] != '#') {
    h[i][j] = true;
    traverse(a, h, i, j - 1, n, m, e);
  }
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(m));
    bool f = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m && !f; j++) {
        if (a[i][j] == 'B') {
          if (a[i][min(m - 1, j + 1)] == 'G' || a[i][max(0, j - 1)] == 'G' ||
              a[max(0, i - 1)][j] == 'G' || a[min(n - 1, i + 1)][j] == 'G') {
            cout << "No" << endl;
            f = true;
          }
        }
      }
    }
    if (f) {
      continue;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] == 'B') {
          change(a, i, j, n, m);
        }
      }
    }
    bool c = false;
    for (int i = 0 && !c && !f; i < n; i++) {
      for (int j = 0 && !c; j < m; j++) {
        if (a[i][j] == 'G') {
          bool e = false;
          vector<vector<bool>> h(n, vector<bool>(m));
          traverse(a, h, i, j, n, m, &e);
          if (e == false) {
            cout << "No" << endl;
            c = true;
            break;
          }
        }
      }
    }
    if (!c) {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
