import sys
for _ in range(int(input())):
n = int(sys.stdin.readline())
flag = "YES"
li = []
for _ in range(n):
li.append(sys.stdin.readline().rstrip('\n'))
li.sort()
for i, j in zip(li, li[1:]):
if i == j[:len(i)]:
flag = "NO"
print(flag)
from collections import deque
def bfs():
q = deque([n])
while q:
x = q.popleft()
if x == k:
return array[x]
for nx in (x-1, x+1, 2*x):
if 0 <= nx < MAX and not array[nx]:
if nx == 2*x and x != 0:
array[nx] = array[x]
q.appendleft(nx) # 2*X 가 더 높은 우선순위를 가지기 위함
else:
array[nx] = array[x] + 1
q.append(nx)
MAX = 100001
n, k = map(int, input().split())
array = [0] * MAX
print(bfs())
x= input()
y= input()
dp = [[0] * (len(y)+1) for _ in range(len(x)+1)]
for i in range(1, len(x)+1):
for j in range(1, len(y)+1):
if x[i-1]==y[j-1]:
dp[i][j] = dp[i-1][j-1] +1
else:
dp[i][j] = max(dp[i][j-1], dp[i-1][j])
print(dp[len(x)][len(y)])