A billionaire won a lottery but he is a big miser so to minimize the people he organizes a party but in a different style.
Each member attending a party is given a name and a single digit number (from 0 to 9). Now they all play a game.
The rules of the game are as follows:
If only one player is playing the game,then he will be the winner.
Otherwise, all the players add the numbers provided to them until they get a single digit number.
If the number obtained is available with any one of the player attending the party, then that player is declared as the winner.
Otherwise the game is declared as a draw.
1 ≤ T ≤ 100
1 ≤ n ≤ 1000
The first line contains T — the number of test cases.
Each test case contains a number n-the number of people attending the party.
Next n lines contains the name and the number separated by space.
If the game is declared as a draw then print “NO”(without double quotes).
Otherwise print the name of the winners in each line and also display the total number of winners.
def sum_digits(n): s = 0 while n: s += n % 10 n //= 10 return s for x in range(int(input())): sum = 0 s =  m =  n = int(input()) for i in range(n): lis = [str(x) for x in input().split()] s.append(lis) m.append(lis) sum = sum + int(lis) no = sum_digits(sum) while(no>=10): no = sum_digits(no) st =  for y in range(len(m)): if int(m[y]) == no: st.append(s[y]) if len(st) == 0: print('NO') else: for z in st: print(z) print(len(st))