#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); long long N,M; cin >> N >> M; vector T(N); for(auto &t : T) cin >> t; vector> A(N,vector(N)); for(auto &h : A) for(auto &w : h) cin >> w; vector> day(1002,vector(N)),OK = day; day.at(0) = T; priority_queue,vector>,greater<>> Q; for(int i=0; i d){ OK.at(let).at(pos)--; Q.push({day.at(let-1).at(pos),let,pos}); continue; } day.at(let).at(pos) = d; for(int to=0; to 1001){ long long d1 = day.at(1001).at(i),d2 = day.at(1000).at(i); long long more = M-1001,d = d1-d2; cout << more*d+d1 << " "; } else cout << day.at(M).at(i) << " "; } cout << endl; }