At the Strehaia informatics contest, participants were given problems to solve. Since the committee wants the scores to be as diverse as possible, the contest organizers decided to calculate the number of distinct scores that can be obtained in the contest.
Task
Given the number of problems and for each problem a number followed by natural numbers representing the number of tests for problem () and the score for each test, determine the number of distinct scores that can be obtained in the contest.
Input data
The first line contains the number of problems in the contest.
The next lines each contain a number followed by numbers, representing the number of tests and the score for each test.
Output data
The first line will contain a single number representing the number of distinct scores that can be obtained in the Strehaia contest.
Constraints and clarifications
- score of a test
- For each problem, the sum of the test scores will be .
# | Points | Constraints |
---|---|---|
1 | 30 | |
2 | 30 | |
3 | 40 | No additional constraints |
Example 1
stdin
2
2 30 70
2 10 90
stdout
15
Explanation
Participants can obtain the following scores:
Example 2
stdin
3
1 100
3 38 12 50
4 93 2 2 3
stdout
137