The time limit is a bit strict.
There are n distinct points on a circle, numbered from 0 to n−1 inclusive in the clockwise order. A circular segment of length ℓ (1≤ℓ≤n) with start at i (0≤i≤n−1) is a tuple of ℓ consecutive points in the clockwise order, starting with i (in other words, a tuple of points with numbers i,(i+1)modn,(i+2)modn,…,(i+ℓ−1)modn). Circular segments of length n with starts at 0,1,…,n−1 are considered to be pairwise different, despite containing the same set of points.
An integer cost c_i,ℓ is assigned to each circular segment. For each k from 1 to n, find the minimum total cost of exactly k circular segments, such that each of the n points is contained in exactly one of them.
Note that there are no properties that values c_i,ℓ satisfy, except being comparatively small positive integers. That is, any n×n array of integers between 1 and 106 is a valid test for this problem.
The first line contains an integer n (1≤n≤850), the number of points on the circle. The (i+1)-st (0≤i≤n−1) of the following n lines contains n space-separated integers c_i,1,c_i,2,…,c_i,n (1≤c_i,ℓ≤106 for 1≤ℓ≤n).
Output n space-separated integers: k-th of them should be the minimum total cost of k circular segments that cover every point exactly once.