wer = int(input())
for ewr in range(wer):
    n,m = list(map(int,input().split(" ")))
    temp = []
    cou = 0
    for i in range(n):
        t1 = input()
        ig = t1.find('G')
        if(ig!=-1):
            cou=1
        temp.append(list(t1))
    if(cou==0):
        print("Yes")
        continue
    flag = 0
    for i in range(n):
        for j in range(m):
            if(temp[i][j]=='B'):
                if(i>0 and flag==0):
                    if(temp[i-1][j]=='G'):
                        flag = 1
                        break
                    elif(temp[i-1][j]!='B'):
                        temp[i-1][j]='#'
                if(i+1<n and flag==0):
                    if(temp[i+1][j]=='G'):
                        flag = 1
                        break
                    elif(temp[i+1][j]!='B'):
                        temp[i+1][j]='#'
                if(j>0 and flag==0):
                    if(temp[i][j-1]=='G'):
                        flag = 1
                        break
                    elif(temp[i][j-1]!='B'):
                        temp[i][j-1]='#'
                if(j+1<m and flag==0):
                    if(temp[i][j+1]=='G'):
                        flag = 1
                        break
                    elif(temp[i][j+1]!='B'):
                        temp[i][j+1]='#'
            if(flag==1):
                break
        if(flag==1):
                break
    if(flag==1 or temp[n-1][m-1]=='#' ):
        print("No")
        continue

    li = []

    li.append([n-1,m-1])
    flag = 0
    while len(li)>0:
        i,j = li.pop(0)
        if(i>0):
            if(temp[i-1][j]!='#' and temp[i-1][j]!='1'):
                temp[i-1][j] = '1'
                li.append([i-1,j])
        if(i+1<n):
            if(temp[i+1][j]!='#' and temp[i+1][j]!='1'):
                temp[i+1][j] = '1'
                li.append([i+1,j])
        if(j>0):
            if(temp[i][j-1]!='#' and temp[i][j-1]!='1'):
                temp[i][j-1] = '1'
                li.append([i,j-1])
        if(j+1<m):
            if(temp[i][j+1]!='#' and temp[i][j+1]!='1'):
                temp[i][j+1] = '1'
                li.append([i,j+1])
    for i in range(n):
        tr = "".join(temp[i])
        ind = tr.find('G')
        if(ind!=-1):
            flag = 1
            break
    if(flag ==1 ):
        print("No")
    else:
        print("Yes")