# -*- coding:utf-8 -*- if __name__ == "__main__": n = input() nums = [0 for i in xrange(10)] inf = float("INF") for i in xrange(n): a,b,c,d,r = raw_input().split() a,b,c,d = int(a),int(b),int(c),int(d) if r == "NO": nums[a] = nums[b] = nums[c] = nums[d] = -inf else: nums[a]+= 1 nums[b]+= 1 nums[c]+= 1 nums[d]+= 1 print nums.index(max(nums))