# coding:utf-8 n = int(input()) yes_list = [] no_list = [str(i) for i in range(10)] taro_list = [] for i in range(n): taro_list.append(input().split()) for k in range(0,n): if taro_list[k][4] == 'YES': for l in taro_list[k][0:4]: yes_list.append(l) elif taro_list[k][4] == 'NO': for l in range(len(no_list)): if no_list[l] in taro_list[k][0:4]: no_list[l] = '-' else: continue if yes_list != []: for m in yes_list: if yes_list.count(str(m)) > 1: print(m) break else: continue else: for m in no_list: if m == '-': continue else: print(m)