n = int(raw_input()) yes = set(range(10)) no = set() for _ in range(n): num, r = raw_input().rsplit(" ",1) if r == "YES": yes = yes & set(map(int,num.split())) else: no = no | set(map(int,num.split())) yes = yes - no print yes.pop()