#!/usr/bin/perl
$n = (@ARGV ? shift @ARGV : int(rand(10)));
$m = (@ARGV ? shift @ARGV : 1000);
print "$n\n";

for ($i = 0; $i < $n-1; ++$i) {
	$g[$i][$i] = 0;
	for ($j = $i+1; $j < $n; ++$j) {
		$g[$i][$j] = int(rand($m))+1; 
	}
}

for ($i = 0; $i < $n; ++$i) {
	for ($j = 0; $j < $n; ++$j) {
		$d = ($i < $j ? $g[$i][$j] : $g[$j][$i]);
		print "$d ";
	}
	print "\n";
}
