it=int(input()) for i in range(it): size=int(input()) a =input() b =input() i = 0 if a != b : print(1) else: print(0)