dp = [1] * 10 for _ in range(int(input())): *x, r = input().split() b = r == 'NO' for i in range(10): dp[i] *= [b, not b][str(i) in x] print(dp.index(1))