#include "bits/stdc++.h" // {{{ using namespace std; #define val const auto #define eb emplace_back #define emp emplace #define fi first #define se second #define X first #define Y second #define outl(x) cout << (x) << '\n' #define rep(i,n) for(int i=0; i < (int)(n); ++i) #define ALL(x) begin(x), end(x) #define TMPLT(T,U) template #define ten(p) ((long long)(1e##p)) #define FILL(a,v) memset((a), (v), sizeof(a)) #define FAST() ios::sync_with_stdio(false), cin.tie(nullptr) #ifndef DEBUG #define debug(...) #define show(x) #define show2(x,y) #define LN() #endif #define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; } template struct Ordered { virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); }; #undef def typedef long long ll; typedef pair pii; namespace ydk{ TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;} TMPLT(T,U) inline bool chmin(T &a, U b){return b gcd(T x, U y) { return (x string mkString(Itr begin, Itr end, const char *sp = " ") { static ostringstream oss; oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)oss << sp; oss << *i; } return oss.str(); } constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; // }}} constexpr int MX = ten(5) + 10; void Xx_main_xX(const int argc, char *argv[]) { // first: id, second:value int N, M; vector buf[11]; int r; cin >> N >> M; rep(i, 10) buf[i].eb(0,0); static int ans[MX]; int before = -1; rep(i, N) { rep(j, M) { cin >> r; if (r == buf[j].back().se) { buf[j].eb(i, r); before = -1; } else if (r > buf[j].back().se) { buf[j].clear(); buf[j].eb(i, r); before = -1; } } if (before < 0) { set U; rep(i, M) { for(const pii& e : buf[i]) U.emp(e.fi); } before = U.size(); } ans[i] = before; } rep(i, N) { outl(ans[i]); } return; } } // {{{ signed main(int argc, char *argv[]){cout << fixed << setprecision(9); ydk::Xx_main_xX(argc, argv); return 0;} // }}}