PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000030. Cắt gỗ (Wood Cutting)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cắt gỗ (Wood Cutting)

Wood Cutting

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn customers. Customer ii requests several wood pieces; the service time is the sum of cutting times for those pieces. Only one customer can be served at a time. A customer's completion time is when all their pieces are done. Minimize the average completion time.

Input

The first line contains nn. Each of the next nn lines starts with kik_i, followed by kik_i cutting times.

Output

Print the minimum average completion time with exactly 10 digits after the decimal point.

Constraints

  • 1≤n≤1051\le n\le 10^5.
  • 1≤ki1\le k_i for 1≤i≤n1\le i\le n.
  • 1≤∑i=1nki≤2⋅1051\le\sum_{i=1}^{n}k_i\le 2\cdot10^5.
  • 1≤ti,j≤1061\le t_{i,j}\le 10^6 for 1≤j≤ki1\le j\le k_i.

Subtasks

  • Subtask 1 (20 points): n≤8n\le 8.
  • Subtask 2 (30 points): n≤30n\le 30.
  • Subtask 3 (50 points): Full constraints.

Examples

Input

3
2 4 6
1 2
3 1 1 1

Output

7.3333333333

Explanation

The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.