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

#BS0000169. R2D2 và đội quân người máy (R2D2 and Droid Army)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

R2D2 và đội quân người máy (R2D2 and Droid Army)

R2D2 and Droid Army

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn droids in a row, numbered from 11 to nn. Each has mm types of components. Droid ii contains ai,ja_{i,j} components of type jj.

R2D2 has a weapon for each type. One shot with weapon jj destroys one component of type jj on every droid that still has such a component. A droid is destroyed when all its components are destroyed.

R2D2 can fire at most kk shots in total. Choose how many shots to fire from each weapon in order to destroy a longest consecutive block of droids. If several optimal choices exist, output any of them. It is not necessary to use all kk shots.

Input

  • The first line contains integers n,m,kn,m,k: number of droids, component types and available shots.
  • Each of the next nn lines contains mm integers ai,1,…,ai,ma_{i,1},\ldots,a_{i,m}, the component counts of the corresponding droid.

Output

Print exactly mm nonnegative integers b1,b2,…,bmb_1,b_2,\ldots,b_m, the shots fired by each weapon. The sum must satisfy ∑j=1mbj≤k\sum_{j=1}^m b_j\le k; the choice must destroy a consecutive block of maximum achievable length.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le30; 1≤m≤21\le m\le2; 0≤k≤10000\le k\le1000; 0≤ai,j≤1000\le a_{i,j}\le100 for all 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.
  • Subtask 2 (30 points): 1≤n≤50001\le n\le5000; 1≤m≤31\le m\le3; 0≤k≤1060\le k\le10^6; 0≤ai,j≤1050\le a_{i,j}\le10^5 for all 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 1≤m≤51\le m\le5; 0≤k≤1090\le k\le10^9; 0≤ai,j≤1080\le a_{i,j}\le10^8 for all 1≤i≤n1\le i\le n, 1≤j≤m1\le j\le m.

Examples

Input

5 2 4
4 0
1 2
2 1
0 2
1 3

Output

2 2

Explanation

There are two weapon types and the budget is four shots. Fire two shots of each type, consuming 2+2=42+2=4 shots.

  • Droid 22 has (1,2)(1,2) components, so it is destroyed.
  • Droid 33 has (2,1)(2,1) components, so it is destroyed.
  • Droid 44 has (0,2)(0,2) components, so it is destroyed.
  • Droid 11 still has two components of type 11; droid 55 still has one component of type 22.

Droids 22 through 44 form a destroyed block of length 33. No block of length 44 can be destroyed within four shots, so this choice is optimal.