func main()
	{ 数値入力待ち:変数N }
	var N: int :: cui@inputInt()
	
	{ 解答配列準備:ans[10] }
	var ans: []int :: #[10]int
	
	{ counter=0 }
	var counter: int :: 0
	
	{ answer=0 }
	var answer: int :: 0
	
	{ i = 0 to N-1 }
	for(0, N - 1)
		{ スペース区切りの文字列受付A_i, B_i, C_i, D_i, R_i }
		var temp: [][]char :: cui@input().split(" ")
		
		{ R_i==YES }
		if(temp[4] = "YES")
			{ ans[A_i]を+1 }
			do ans[temp[0].toInt(&)] :+ 1
			{ ans[B_i]を+1 }
			do ans[temp[1].toInt(&)] :+ 1
			{ ans[C_i]を+1 }
			do ans[temp[2].toInt(&)] :+ 1
			{ ans[D_i]を+1 }
			do ans[temp[3].toInt(&)] :+ 1
			{ counterを+1 }
			do counter :+ 1
		else
			{ ans[A_i]を-1 }
			do ans[temp[0].toInt(&)] :- 1
			{ ans[B_i]を-1 }
			do ans[temp[1].toInt(&)] :- 1
			{ ans[C_i]を-1 }
			do ans[temp[2].toInt(&)] :- 1
			{ ans[D_i]を-1 }
			do ans[temp[3].toInt(&)] :- 1
		end if
	end for
	
	{ i = 0 to 9 }
	for i(0, 9)
		{ ans[i]>=counter }
		if a(ans[i] >= counter)
			{ answer = i }
			do answer :: i
			break a
		end if
	end for
	
	do cui@print("\{answer}\n")
end func