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 - 1).each do |y|
            hash[y] = [] unless hash.has_key?(y)
            (x1..x2 - 1).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?(v - 1)
                cir += 1 unless val.include?(v + 1)
                cir += 1 unless hash.has_key?(key - 1) && hash[key - 1].include?(v)
                cir += 1 unless hash.has_key?(key + 1) && hash[key + 1].include?(v)
            end
        end
    end
    puts area
    puts cir if r == 2
end