strehaia

Time limit: 0.2s Memory limit: 32MB Input: Output:

At the Strehaia informatics contest, participants were given nn 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 nn of problems and for each problem a number mm followed by mm natural numbers representing the number of tests for problem ii (1in1 \leq i \leq n) 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 nn of problems in the contest.

The next nn lines each contain a number mm followed by mm 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

  • 1n10 0001 \leq n \leq 10\ 000
  • 11 \leq score of a test 100\leq 100
  • For each problem, the sum of the test scores will be 100100.
# Points Constraints
1 30 1n201 \leq n \leq 20
2 30 1n1 0001 \leq n \leq 1\ 000
3 40 No additional constraints

Example 1

stdin

2
2 30 70
2 10 90

stdout

15

Explanation

Participants can obtain the following scores:

0+0=00 + 0 = 0

0+10=100 + 10 = 10

30+0=3030 + 0 = 30

30+10=4030 + 10 = 40

70+0=7070 + 0 = 70

70+10=8070 + 10 = 80

0+90=900 + 90 = 90

100+0=100100 + 0 = 100

100+10=110100 + 10 = 110

30+90=12030 + 90 = 120

30+100=13030 + 100 = 130

70+90=16070 + 90 = 160

70+100=17070 + 100 = 170

100+90=190100 + 90 = 190

100+100=200100 + 100 = 200

Example 2

stdin

3
1 100
3 38 12 50
4 93 2 2 3

stdout

137

Log in or sign up to be able to send submissions!