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.
The input consists of a single test case in the following format.
n
s1 c1
s2 c2
...
...
sn cn
The first line contains one integer n satisfying 1 ≤ n ≤ 20. n 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.
Print the number of ways that Roy can withdraw his courses to meet the above condition.