  while str = gets do
    num, r = str.chomp.split(" ").map(&:to_i)
    hash = {}
    num.times do |n|
      x1, y1, x2, y2 = gets.chomp.split(" ").map(&:to_i)
      (y1..y2).each do |y|
        hash[y] = [] unless hash.has_key?(y)
        (x1..x2).each do |x|
          hash[y] << x unless hash[y].include?(x)
        end
      end
    end
    area = 0
    hash.each do |key, val|
      area += val.length
    end
    cir = 0
    if r == 2
      hash.each do |key, val|
        val.each do |v|
          cir += 1 unless val.include?(val - 1)
          cir += 1 unless val.include?(val + 1)
          cir += 1 unless hash.has_key?(key - 1) && hash[key - 1].include?(val)
          cir += 1 unless hash.has_key?(key + 1) && hash[key + 1].include?(val)
        end
      end
    end
    puts area
    puts cir if r == 2
  end