N = int(input()) states = [0 for _ in range(10)] ns = [list(input().split()) for _ in range(N)] for nl in ns: r, indexes = nl[-1], list(map(int, nl[:-1])) for i in indexes: states[i] = 2 if (r == 'NO') or not states[i] else 1 ans_index = states.index(1) if 1 in states else states.index(0) print(ans_index)