eolymp
bolt
Try our new interface for solving problems
Problems

A granite of science

A granite of science

At the university, where Alex studies, the new semester has begun.The new semester brings to Alex N new subjects, and each subject will be held every day.Before the beginning of the semester Alex learned how many lessons scheduled for each of the objects: for i-th subject planned N_i lessons for all i one to N.In addition, some of senior students said Alex the difficulty of each of the subjects: the number of H_ij for all i and j denotes the difficulty of j-th lesson i-th subject. Many teachers have not yet returned from holidays, so the lessons of some subjects will not start immediately. More specifically, the first day of lesson for each subject can be determined with equal probability of the first M days of semester. May even happen that the first day in university can be without lessons at all. Once first lessons of any subject has begun, they are held regularly, one lesson per day, until all N_i lessons will not end. During his studies, Alex gets tired. He thought that total fatigue of one day is the square of sum of fatigue of all lessons this day. To better understand what expect, Alex wants to know total fatigue of the entire semester. Since Alex does not know exactly when lessons would start, he is interested in the average value. \textbf{Limit} 1 \textit{≤ N ≤ }500 1 \textit{≤ M ≤ }500 1 \textit{≤ Ni ≤ }500 0 \textit{≤ Hij ≤ }1000 \InputFile The first line contains two integers: N and M. Each of the next N rows corresponds to one subject and contains an integer N_i --- number of lessons of the subject, --- and N_i integers H_ij --- the difficulty of each these lessons. \OutputFile You should print a single number --- the total value of Alex’s fatigue per semester. Print the answer with absolute or relative error of less than 10 ^7.
Time limit 1 second
Memory limit 256 MiB
Input example #1
2 1
1 1
1 2
Output example #1
9.000000000
Author Евгений Капун
Source Зимняя школа по программированию 2014, Харьков