while true
  n,r = gets.split(" ").map{|s| s.to_i}
  break if (n==0 && r==0)
  
  a = Array.new(n){gets.split(" ").map{|s| s.to_i}}.transpose
  
  xmax,ymax = a[2].max,a[3].max
  puts xmax
  puts ymax if r==2
end