$o=Array.new(10001*10001){0}
def a;gets.split.map(&:to_i);end
def m i,j;$o[i*10001+j];end
n,r=a
n.times{x,y,t,u=a
(x...t).each{|i|(y...u).each{|j|$o[i*10001+j]=1}}}
p $o.count 1
p (0...10000).inject(0){|s,i|s+(0...10000).inject(0){|d,j|d+((m(i,j)==0)?0:(4-m(i-1,j)-m(i+1,j)-m(i,j-1)-m(i,j+1)))}} if r==2