sub nextq {
my $sz=8;
(print("@_\n"),return) if @_ == $sz;
o: foreach my $col(0..$sz-1) {
my($u,$d)=(scalar(@_),scalar(@_));
for (@_) {next o if($_==$col or $_==$col-$u-- or $_==$col+$d--)}
nextq(@_,$col);
}
}
nextq();