for _ in range(int(input())):
n1, n2 = input(), input()
print(f"Hamming distance is {sum(n1[i] != n2[i] for i in range(len(n1)))}.")
for _ in range(int(input())):
n1, n2 = input(), input()
print(f"Hamming distance is {sum(n1[i] != n2[i] for i in range(len(n1)))}.")