public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        HDOJ1070 hdoj1070=new HDOJ1070();
        int cases=scanner.nextInt();
        while (cases-->0){
            int milkCnt=scanner.nextInt();
            List<Milk> milks=new ArrayList<>();
            while (milkCnt-->0) {
                Milk milk = new Milk(scanner.next(), scanner.nextInt(), scanner.nextInt());
                if(milk.days>0) milks.add(milk);
            }
            System.out.println(hdoj1070.entrance(milks));
        }
    }