n = int(input()) l = [6] * 10 for _ in range(n): a, b, c, d, r = input().split() l2 = [a, b, c, d] for i in l2: if r == 'NO': l[int(i)] -=1 else: l[int(i)] += 1 print(l.index(max(l)))