import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int[] maxes = new int[m]; ArrayList> tops = new ArrayList<>(); for (int i = 0; i < m; i++) { tops.add(new HashSet<>()); } int[] counts = new int[n]; int ans = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int x = sc.nextInt(); if (maxes[j] < x) { for (int y : tops.get(j)) { counts[y]--; if (counts[y] == 0) { ans--; } } tops.get(j).clear(); tops.get(j).add(i); maxes[j] = x; counts[i]++; } else if (maxes[j] == x) { tops.get(j).add(i); counts[i]++; } } if (counts[i] > 0) { ans++; } sb.append(ans).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }