a,*X=$<.map{_1.split.map(&:to_i).sort} X.sort!.map{|x|$*<_2}?d+1:1}.max||1} p$*.max