import sys t = int(raw_input()) data = [] for i in range(t): n = int(raw_input()) temp = [] for j in range(n): temp.append(sys.stdin.readline().strip()) data.append(temp) def sub(A, B): return len(A) == len(B) and B in A + A def sub2(num): for j in range(len(num)-...