11808 - EECS_I2P17_FINAL_D   

Description

From  I2P CS 2017 Fall Chen Final Exam

At the end of the semester, Roy Feng is bombarded (轟炸) by all kinds of final exams, reports, and projects. He regrets that he didn’t make the course withdrawal at the middle of the semester.

According to the rule, without any underload application, freshmen should take at least 16 credits (學分) each semester after course withdrawal. Given all the courses Roy took at the begin of the semester, your task is to help Roy to figure out how many ways he can withdraw his courses to satisfy the above rule. Each way should withdraw at least one of them.

Input

The input consists of a single test case in the following format.

n

s1 c1

s2 c2

...

...

scn

The first line contains one integer n satisfying 1 ≤ n ≤ 20n denotes the total number of courses Roy took at the begin of the semester. The next n lines show the information of courses. The i-th line of them contains a string si whose length is between 1 and 100, inclusive, and an integer ci satisfying 0 ≤ ci ≤ 4, meaning that the i-th course is taken by Roy with the name si and the credit ci.

Output

Print the number of ways that Roy can withdraw his courses to meet the above condition.

Sample Input  Download

Sample Output  Download

Tags




Discuss