import java.util.*; class N024{ public static void main(String args[]){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int e[] = new int[10]; int count; for(int i = 0; i < n; i++){ int a = s.nextInt(); int b = s.nextInt(); int c = s.nextInt(); int d = s.nextInt(); String r = s.next(); if(r.equals("YES")){ count = 1; }else{ count = -1; } e[a] += count; e[b] += count; e[c] += count; e[d] += count; } int max = 0; for(int i = 0; i < e.length; i++){ System.out.println(e[i]); max = Math.max(max , e[i]); } for(int i = 0; i < e.length; i++){ if(e[i] == max){ System.out.println(i); } } } }