#0000A3

z-javelin

Mr. Little Z decided to try himself as javelin thrower. He will try to throw the javelin N times. At each throw i he is speeding up until some moment t1i and for the next ti seconds he is running with a constant speed. After ti he is slowing down.

At each full second (integer value of seconds) in the interval [ t1i, t1i + ti ] he can throw the javelin. Javelin thrown at the moment t1i + t will fall at the position t1i + t * ki, 0 <= t <= ti.


Making N throws, Mr. Little Z wonders what is the number of possible different positions that could be hit during these tries. Hitting position pos at try i and try j counts as only one unique position pos.


InputFirst line of standard input will contain integer N (1 <= N <= 100 000). Next N lines will contain three space-separated integers. Line i + 1 will contain t1i (1 <= t1i <= 100 000), ti (0 <= ti <= 100 000) and ki (1 <= ki <= 10), Also, it will always be true that t1i + t * ki <= 100 000.


OutputTo standard output you should print one integer that represents number of different positions that Mr. Little Z. might have hit.

Input:
2
7 4 5
10 7 2

Output:
11

Explanation:
In the first try Mister Little Z could have hit the following positions:
7 + 0*5 = 7
7 + 1*5 = 12
7 + 2*5 = 17
7 + 3*5 = 22
7 + 4*5 = 27
And in the second try he could have hit:
10 + 0*2 = 10
10 + 1*2 = 12
10 + 2*2 = 14
10 + 3*2 = 16
10 + 4*2 = 18
10 + 5*2 = 20
10 + 6*2 = 22
10 + 7*2 = 24

So there are 11 unique possible positions: 7, 10, 12, 14, 16, 17, 18, 20, 22, 24, and 27

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.