X=$<.map{_1.split.map(&:to_i).sort}[1..].sort r=0..$.-2;p r.map{|i|$*[i]=r.map{|j|X[i].zip(X[j]).all?{_1>_2}?$*[j]:0}.max+1}.max