require 'pp'
loop do
  area = Hash.new{Hash.new}

  n, r = gets.split.map(&:to_i)
  break if n == 0

  n.times do
    x1, y1, x2, y2 = gets.split.map(&:to_i)
    (x1 ... x2).each do |x|
      (y1 ... y2).each do |y|
        area[x] = area[x]
        area[x][y] = true
      end
    end
  end

  puts area.inject(0){|a, b| a + b[1].each_value.count(true)}

  if r == 2
    res = 0
    area.each do |x, vx|
      vx.each do |y, vy|
        res += 1 unless area[x - 1][y]
        res += 1 unless area[x + 1][y]
        res += 1 unless area[x][y - 1]
        res += 1 unless area[x][y + 1]
      end
    end
    puts res
  end
end