n = int(input())for i in range(n): x = input() if sum([int(k) for k in list(x[:3])]) == sum([int(k) for k in list(str(int(x[3:])+1))]) or sum([int(k) for k in list(x[:3])]) == sum([int(k) for k in list(str(int(x[3:])-1))]): print('Yes') else: print('No')
3 715068 445219 012200
Yes No Yes
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!