#include <bits/stdc++.h>
using namespace std;
long long int m = 998244353;
long long int mod = 1000000000;
long long int modularExponentiation(long long int x, long long int n) {
  x = abs(x);
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modularExponentiation((x * x) % m, n / 2) % m;
  else
    return (x * (modularExponentiation((x * x) % m, (n - 1) / 2))) % m;
}
long long int GCD(long long int a, long long int b) {
  if (a == 0) return b;
  return GCD(b % a, a);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    string str[n + 2], sit;
    for (int i = 0; i < m + 2; i++) {
      str[0] += '#';
      str[n + 1] += '#';
    }
    for (int i = 1; i < n + 1; i++) {
      cin >> sit;
      str[i] = '#' + sit + '#';
    }
    int flag = 0, g = 0;
    for (int i = 0; i < n + 2; i++) {
      for (int j = 0; j < m + 2; j++) {
        if (str[i][j] == 'G') g++;
        if (str[i][j] == 'B') {
          if (str[i + 1][j] == '.' || str[i + 1][j] == '#')
            str[i + 1][j] = '#';
          else if (str[i + 1][j] == 'G')
            flag = 1;
          if (str[i - 1][j] == '.' || str[i - 1][j] == '#')
            str[i - 1][j] = '#';
          else if (str[i - 1][j] == 'G')
            flag = 1;
          if (str[i][j + 1] == '.' || str[i][j + 1] == '#')
            str[i][j + 1] = '#';
          else if (str[i][j + 1] == 'G')
            flag = 1;
          if (str[i][j - 1] == '.' || str[i][j - 1] == '#')
            str[i][j - 1] = '#';
          else if (str[i][j - 1] == 'G')
            flag = 1;
        }
      }
      if (flag == 1) break;
    }
    if (g == 0) {
      cout << "Yes" << endl;
      continue;
    }
    if ((str[n][m] == '#' && g) || flag == 1) {
      cout << "No" << endl;
      continue;
    } else
      str[n][m] = 'R';
    for (int i = n + 1; i >= 0; i--) {
      for (int j = m + 1; j >= 0; j--) {
        if (str[i][j] == 'R') {
          if (str[i + 1][j] == '.' || str[i + 1][j] == 'G') str[i + 1][j] = 'R';
          if (str[i - 1][j] == '.' || str[i - 1][j] == 'G') str[i - 1][j] = 'R';
          if (str[i][j + 1] == '.' || str[i][j + 1] == 'G') str[i][j + 1] = 'R';
          if (str[i][j - 1] == '.' || str[i][j - 1] == 'G') str[i][j - 1] = 'R';
        }
      }
    }
    int co = 0;
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < m + 1; j++) {
        if (str[i][j] == 'G') co++;
      }
    }
    if (co)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}
