number = [True, True, True, True, True, True, True, True, True, True] def listchange(inpt): if inpt[4] == 'YES': for i in range(0, 10): if not(str(i) in inpt): number[i] = False else: for i in range(0, 4): number[int(inpt[i])] = False n = int(raw_input()) for i in range(0, n): inpt = raw_input().split() listchange(inpt) for i in range(0, 10): if number[i]: print i break