#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int i, j;
    char a[n + 2][m + 2];
    int res = 0, res1 = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] == 'G') {
          res = res + 1;
        } else {
          res1 = res1 + 1;
        }
      }
    }
    if (res == 0) {
      cout << "Yes" << endl;
      continue;
    }
    int ans = 1;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        int x = i;
        int y = j;
        if (a[x][y] == 'B') {
          if (x - 1 >= 0 && a[x - 1][y] == 'G') {
            ans = 0;
          }
          if (x + 1 < n && a[x + 1][y] == 'G') {
            ans = 0;
          }
          if (y + 1 > m && a[x][y + 1] == 'G') {
            ans = 0;
          }
          if (y - 1 >= 0 && a[x][y - 1] == 'G') {
            ans = 0;
          }
        }
      }
      if (ans == 0) {
        break;
      }
    }
    if (ans == 0) {
      cout << "No";
    } else if (n - 2 >= 0 && a[n - 2][m] == 'B') {
      cout << "No";
    } else if (m - 2 >= 0 && a[n][m - 2] == 'B') {
      cout << "No";
    } else {
      int ans = 1;
      for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
          if (a[i][j] == 'G') {
            queue<int> p, q;
            p.push(i);
            q.push(j);
            int f = 0;
            while (!p.empty() && f == 0) {
              int x = p.front();
              int y = q.front();
              p.pop();
              q.pop();
              if (x == n - 1 && y == m - 1) {
                f = 1;
              }
              if (x - 1 >= 0 && (a[x - 1][y] == '.' || a[x - 1][y] == 'G')) {
                p.push(x - 1);
                q.push(y);
              }
              if (x + 1 < n && (a[x + 1][y] == '.' || a[x + 1][y] == 'G')) {
                p.push(x + 1);
                q.push(y);
              }
              if (y - 1 >= 0 && (a[x][y - 1] == '.' || a[x][y - 1] == 'G')) {
                p.push(x);
                q.push(y - 1);
              }
              if (y + 1 < m && (a[x][y + 1] == '.' || a[x][y + 1] == 'G')) {
                p.push(x);
                q.push(y + 1);
              }
            }
            if (f == 0) {
              ans = 0;
              break;
            }
          }
          if (ans == 0) {
            break;
          }
        }
      }
      if (ans == 0) {
        cout << "No";
      } else {
        cout << "Yes";
      }
    }
    cout << endl;
  }
}
