Chess960 is a variant of chess created by world champion Bobby Fischer. Unlike other variants of the game, Chess960 does not require a different material, but instead relies on a random initial position, with a few constraints:

 as in the standard chess game, all eight white pawns must be placed on the second rank.
 White pieces must stand on the first rank as in the standard game, in random column order but with the two following constraints:
 the bishops must be placed on opposite color squares (i.e. they must be an odd number of spaces apart or there must be an even number of spaces between them)
 the King must be between two rooks (with any number of other pieces between them all)
 Black pawns and pieces must be placed respectively on the seventh and eighth ranks, mirroring the white pawns and pieces, just as in the standard game. (That is, their positions are not independently randomized.)


With those constraints there are 960 possible starting positions, thus the name of the variant.



Task

The purpose of this task is to write a program that can randomly generate any one of the 960 Chess960 initial positions. You will show the result as the first rank displayed with Chess symbols in Unicode: ♔♕♖♗♘ or with the letters King Queen Rook Bishop kNight.




/*REXX program generates a random starting position  for the  Chess960  game. */
parse arg seed .                       /*allow for (RANDOM BIF) repeatability.*/
if seed\==''  then call random ,,seed  /*if SEED was specified,  use the seed.*/
@.=.                                   /*define the first rank as being empty.*/
r1=random(1,6)                         /*generate the first rook:  rank 1.    */
@.r1='R'                               /*place the  first rook  on  rank1.    */
          do  until  r2\==r1  &  r2\==r1-1  &  r2\==r1+1
          r2=random(1,8)               /*find placement for the 2nd rook.     */
          end   /*forever*/
@.r2='r'                               /*place the second rook  on  rank 1.   */
k=random(min(r1, r2)+1, max(r1, r2)-1) /*find a random position for the king. */
@.k='K'                                /*place king between the two rooks.    */
          do _=0      ; b1=random(1,8);  if @.b1\==.  then iterate;  c=b1//2
            do forever; b2=random(1,8)       /* c=color of bishop ►──┘        */
            if @.b2\==. | b2==b1 | b2//2==c  then iterate /*is a bad position?*/
            leave _                    /*found position for the 2 clergy*/
            end   /*forever*/          /* [↑]  find a place for the 1st bishop*/
          end     /* _ */              /* [↑]    "  "   "    "   "  2nd    "  */
@.b1='B'                               /*place the  1st  bishop on  rank 1.   */
@.b2='b'                               /*  "    "   2nd     "    "    "  "    */
                                       /*place the two knights on rank 1.     */
   do  until @._='N';  _=random(1,8);   if @._\==.  then iterate; @._='N';   end
   do  until @.!='n';  !=random(1,8);   if @.!\==.  then iterate; @.!='n';   end
_=                                     /*only the queen is left to be placed. */
   do i=1  for 8;  _=_ || @.i;   end   /*construct the output: first rank only*/
say translate(translate(_, 'q', .))    /*stick a fork in it,  we're all done. */