($h,$w)=glob<>; if($h&1){ if($w&1){ if($h>$w){ print $h*($w-1),$/; for$y(1..$h){ for$x(1..$w){ print $x==($y<$w?$y:$w)?0:1; print $x==$w?$/:$"; } } }else{ print +($h-1)*$w,$/; for$y(1..$h){ for$x(1..$w){ print $y==($x<$h?$x:$h)?0:1; print $x==$w?$/:$"; } } } }else{ print +($h-1)*$w,$/; print "@{[(1)x$w]}\n"x($h-1); print "@{[(0)x$w]}\n"; } }else{ if($w&1){ print $h*($w-1),$/; print "@{[(1)x($w-1),0]}\n"x$h; }else{ print $h*$w,$/; print "@{[(1)x$w]}\n"x$h; } }