2596. Galaxy Wide Web Service

单点时限: 5.0 sec

内存限制: 256 MB

The volume of access to a web service varies from time to time in a day. Also, the hours with the highest volume of access varies from service to service. For example, a service popular in the United States may receive more access in the daytime in the United States, while another service popular in Japan may receive more access in the daytime in Japan. When you develop a web service, you have to design the system so it can handle all requests made during the busiest hours.

You are a lead engineer in charge of a web service in the 30th century. It’s the era of Galaxy Wide Web (GWW), thanks to the invention of faster-than-light communication. The service can be accessed from all over the galaxy. Thus many intelligent creatures, not limited to human beings, can use the service. Since the volume of access to your service is increasing these days, you have decided to reinforce the server system. You want to design a new system that handles requests well even during the hours with the highest volume of access. However, this is not a trivial task. Residents in each planet have their specific length of a day, say, a cycle of life. The length of a day is not always 24 hours. Therefore, a cycle of the volume of access are different by planets of users.

You have obtained hourly data of the volume of access for all planets where you provide the service.Assuming the volume of access follows a daily cycle for each planet, you want to know the highest volume of access in one hour. It should be a quite easy task for you, a famous talented engineer in the galaxy.

输入格式

The input is formatted as follows.

N

d1 t1 q1,0 . . . q1,d1-1

. . .

dN tN qN,0 . . . qN,dN-1

N is the number of planets. di (1 ≤ i ≤ N) is the length of a day in the planet i. qi, j is the volume of access on the planet i during from the j-th hour to the ( j + 1)-th hour. You may assume that N ≤ 100, di ≤ 24, qi, j ≤ 1000000 (1 ≤ i ≤ N, 0 ≤ j ≤ di-1).

输出格式

Output the maximum volume of access in one hour in a line.

样例

Input
2
4 0 1 2 3 4
2 0 2 1
Output
5

1 人解决,3 人已尝试。

2 份提交通过,共有 64 份提交。

9.9 EMB 奖励。

创建: 14 年,6 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: Japan

题目标签