($w, $h, $n) = split/ /,<>;
@xy = <>;
@pyr = @a = (0) x ($w + 1);
for $i(1..$n){
($x, $y)= split/ /, $xy[$i-1]; if (abs($x-$y) >= $h - $pyr[$y]){ }
$a[$y]++;
$pyr[$y] < $a[$y] and $pyr[$y] = $a[$y];
$j = $y;
while($j > 1 and $pyr[$j-1] < $pyr[$j]-1){
$pyr[--$j]++
}
$j = $y;
while($j < $w and $pyr[$j+1] < $pyr[$j]-1){
$pyr[++$j]++
}
print "\@pyr: @pyr", "\n---",$/; }
KCR3LCAkaCwgJG4pID0gc3BsaXQvIC8sPD47CgpAeHkgPSA8PjsKY2hvbXAgQHh5OwoKQHB5ciA9IEBhID0gKDApIHggKCR3ICsgMSk7Cgpmb3IgJGkoMS4uJG4pewoJKCR4LCAkeSk9IHNwbGl0LyAvLCAkeHlbJGktMV07CglpZiAoYWJzKCR4LSR5KSA+PSAkaCAtICRweXJbJHldKXsKCQlwcmludCAiYmFkIGFuc3dlcjogIjsKCQlwcmludCAkaSwgJC87CgkJZXhpdAoJCX0KCQoJJGFbJHldKys7CgkkcHlyWyR5XSA8ICRhWyR5XSBhbmQgJHB5clskeV0gPSAkYVskeV07CgkKCSRqID0gJHk7Cgl3aGlsZSgkaiA+IDEgYW5kICRweXJbJGotMV0gPCAkcHlyWyRqXS0xKXsKCQkkcHlyWy0tJGpdKysKCQl9CgkKCSRqID0gJHk7Cgl3aGlsZSgkaiA8ICR3IGFuZCAkcHlyWyRqKzFdIDwgJHB5clskal0tMSl7CgkJJHB5clsrKyRqXSsrCgkJfQoJCQoJcHJpbnQgIlxAYSAgOiBAYSIsJC87CglwcmludCAiXEBweXI6IEBweXIiLCAiXG4tLS0iLCQvOwoJfQoKcHJpbnQgImdvb2QgYW5zd2VyOiAiOwpwcmludCAwLCAkLw==