import sys input = sys.stdin.readline def solve(): H,W = map(int, input().split()) A = [[c for c in input()] for i in range(H)] # for i in range(H-1): # l = 0 # r = 0 # while l < W: # B = [c.replace('?', '#') for c in A[i]] # while r < W and B[l] == B[r]: # r += 1 # if B[l] == '#': # pre = False #2つ以上前に壁を設置できるか # pre2 = False #直前を.にできるか # # for j in range(l, r): # # if A[i+1][j] != '.' and pre and pre2: # # print("Yes") # # return # # if j > l and A[i+1][j-1] != '.': # # pre = True # # if A[i+1][j] == '#': # # pre2 = False # # else: # # pre2 = True # l = r for i in range(H-1): for j in range(W): print(A[i][j]) print("No") for i in range(int(input())): solve()