def chk(a,n,m):
    for i in range(n):
        for j in range(m):
            if a[i][j]=='B':
                if i==n-1 and j==m-1:
                    return 0
                if i==n-1 and j==0:
                    if a[i][(j+1)%m]=='G' or a[i-1][j]=='G':
                        return 0
                elif i==n-1:
                    if a[i][(j+1)%m]=='G' or a[i-1][j]=='G' or a[i][j-1]=='G':
                        return 0
                elif i==0 and j==0:
                    if a[i][(j+1)%m]=='G' or a[(i+1)%n][j]=='G':
                        return 0
                elif i==0 and j==m-1:
                    if a[i][(j-1)]=='G' or a[(i+1)%n][j]=='G':
                        return 0
                elif i==0:
                    if a[i][(j-1)]=='G' or a[(i+1)%n][j]=='G' or a[i][(j+1)%m]=='G':
                        return 0
                elif j==0:
                    if a[i][(j+1)%m]=='G' or a[(i+1)%n][j]=='G' or a[(i-1)%n][j]=='G':
                        return 0
                elif j==m-1:
                    if a[i][(j-1)%m]=='G' or a[(i+1)%n][j]=='G' or a[(i-1)%n][j]=='G':
                        return 0
                else:
                    if a[i][(j-1)%m]=='G' or a[i][(j+1)%m]=='G' or a[(i+1)%n][j]=='G' or a[(i-1)%n][j]=='G':
                        return 0
    return 1
def place(a,i,j,n,m):
    if a[i][j]=='B' or a[i][j]=='#':
        return 0
    for it in range(1):
                if i==n-1 and j==0:
                    if a[i][(j+1)%m]=='B' or a[i-1][j]=='B':
                        return 0
                elif i==n-1:
                    if a[i][(j+1)%m]=='B' or a[i-1][j]=='B' or a[i][j-1]=='B':
                        return 0
                elif i==0 and j==0:
                    if a[i][(j+1)%m]=='B' or a[(i+1)%n][j]=='B':
                        return 0
                elif i==0 and j==m-1:
                    if a[i][(j-1)]=='B' or a[(i+1)%n][j]=='B':
                        return 0
                elif i==0:
                    if a[i][(j-1)]=='B' or a[(i+1)%n][j]=='B' or a[i][(j+1)%m]=='B':
                        return 0
                elif j==0:
                    if a[i][(j+1)%m]=='B' or a[(i+1)%n][j]=='B' or a[(i-1)%n][j]=='G':
                        return 0
                elif j==m-1:
                    if a[i][(j-1)%m]=='B' or a[(i+1)%n][j]=='B' or a[(i-1)%n][j]=='G':
                        return 0
                else:
                    if a[i][(j-1)%m]=='B' or a[i][(j+1)%m]=='B' or a[(i+1)%n][j]=='B' or a[(i-1)%n][j]=='B':
                        return 0
    if i==n-1 and j==m-1:
        return 1
    if i==n-1:
        return place(a,i,j+1,n,m)
    if j==m-1:
        return place(a,i+1,j,n,m)
    else:
        return max(place(a,i,j+1,n,m),place(a,i+1,j,n,m))
for _ in range(input()):
    n,m=[int(i) for i in raw_input().split()]
    a=[[i for i in raw_input()]for j in range(n)]
    if a[n-2][m-1]=='B' or a[n-1][m-2]=='B':
        a[n-1][m-1]='#'
    if chk(a,n,m)==0:
        print "No"
        continue
    flag=1
    for i in range(n):
        for j in range(m):
            if a[i][j]=='G':
                if place(a,i,j,n,m)==0:
                    flag=0
    if flag==1:
        print "Yes"
    else:
        print "No"
