my $N = shift ;
my $M = shift ;
my $B = shift ;
print "$N $M $B\n" ;
my $src = int rand $N ;
my $dst = int rand $N ;
while ($dst == $src) {
   $dst = int rand $N ;
}
print "$src $dst\n" ;
for ($i=0; $i<$M; $i++) {
   my $from = int rand $N ;
   my $to = int rand $N ;
   while ($from == $to || $seen{"$from $to"}++) {
      $from = int rand $N ;
      $to = int rand $N ;
   }
   $lowid = int rand $B ;
   $highid = int rand $B ;
   ($lowid, $highid) = ($highid, $lowid) if $lowid > $highid ;
   print "$from $to $lowid $highid\n" ;
}
