import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): N = int(input()) ABCDR = [[x for x in input().split()] for _ in range(N)] ans = [0] * 10 for a, b, c, d, r in ABCDR: if r == "NO": ans[int(a)] -= 1 ans[int(b)] -= 1 ans[int(c)] -= 1 ans[int(d)] -= 1 else: ans[int(a)] += 1 ans[int(b)] += 1 ans[int(c)] += 1 ans[int(d)] += 1 print(ans.index(max(ans))) if __name__ == '__main__': main()