if __name__ == '__main__': yes_list = [] no_list = [] n = int(input()) for _ in range(n): *numbers, r = input().split() (yes_list if r == 'YES' else no_list).extend(map(int, numbers)) memo = list(range(10)) for x in no_list: memo[x] = None l = len(yes_list) if l == 0: answer = [x for x in range(10) if memo[x] is not None] if l == 4: answer = [x for x in range(10) if x in yes and memo[x] is not None] if l > 4: answer = [x for x in range(10) if yes_list.count(x) > 1 and memo[x] is not None] print(answer[0])