Python code
T = int(input())
for tc in range(1, T+1):
N = int(input())
cnt = 0
for i in range(N):
word = input()
use = []
flag = 1
for i in range(len(word)):
if word[i] not in use:
use.append(word[i])
else:
if word[i] == word[i-1]:
pass
else:
flag = 0
if flag == 1:
cnt += 1
print(cnt)