// var lineIdx = 0;
// var readline = () => {
//   var input = ["1", "2 2", "#B", "G."]
//   return input[lineIdx++];
// };
// var print = (str) => {
//   console.log(str);
// };

var t = readline().split(" ").map(function(x) { return parseInt(x); })[0];

var matrix = new Array();
var mSize=0;

var initMatrix = (n, m) => {
  matrix = new Array(n*m);
  mSize = n;
}

var getMatrix = (n, m) => {
  return matrix[mSize*n + m];
}

var setMatrix = (n, m, v) => {
  matrix[mSize*n + m] = v;
}

var step = () => {
  var inp = readline().split(" ").map(function(x) { return parseInt(x); });
  var n = inp[0];
  var m = inp[1];
  initMatrix(n, m);
  setMatrix(n-1, m-1, 2)
  var g = [];


  for(var i = 0; i < n; i++){
    var row = readline();
    for(var j = 0; j < m; j++){
      if(row[j] == "#"){
        setMatrix(i, j, 1);
      }
      else if(row[j] == "B"){
        setMatrix(i, j, -1);
        if(i > 0){
          setMatrix(i - 1, j, -1)
        }
        if(i < n - 1){
          setMatrix(i + 1, j, -1)
        }
        if(j > 0){
          setMatrix(i, j-1, -1)
        }
        if(j < m - 1){
          setMatrix(i, j+1, -1)
        }
      }
      else if(row[j] == "G"){
        g.push({i, j});
      }
    }
  }

  if(g.length == 0){
    print("Yes");
    return;
  }

  var dyn = (i, j) => {
    var res = getMatrix(i, j);

    if(res == -1 || res == 1){
      return 1;
    }

    if(res == 2){
      return 2;
    }


    setMatrix(i, j, 1)
    var fin = 1;
    if(i > 0){
      fin = Math.max(fin, dyn(i - 1, j, -1))
    }
    if(i < n - 1){
      fin = Math.max(fin,dyn(i + 1, j, -1))
    }
    if(j > 0){
      fin = Math.max(fin,dyn(i, j-1, -1))
    }
    if(j < m - 1){
      fin = Math.max(fin,dyn(i, j+1, -1))
    }
    setMatrix(i, j, fin)
    return fin
  }

  var rr = g.every(item => {
     dyn(item.i, item.j);
     return getMatrix(item.i, item.j) == 2
  });

  if (rr){
    print("Yes")
  }
  else{
    print("No")
  }


}

for(var i1 = 0; i1 < t; i1++){
  step();
}

