from collections import Counter n = int(input()) yes = [] no = [] y_flag = 0 n_flag = 0 for i in range(n): a = input().split() if a[-1] == 'YES': yes.extend(a[:-1]) y_flag += 1 else: no.extend(a[:-1]) n_flag += 1 c = Counter(yes) if y_flag == 0: print(''.join([str(i) for i in range(0, 10) if str(i) not in no])) elif n_flag == 0: print(c.most_common(1)) else: if y_flag > 1: yes = [i for i in set(yes) if yes.count(i) > 1] for i in range(len(yes)): if yes[i] not in no: print(yes[i]) exit()