#!ruby -p n=eval$_ $_='RKR ' ([*[*0..4].combination(j=2)][n/96]+[n/16%6]+[n%4*2+1,n/4%4*2].sort).map{|i|$_[i,0]='NNBBQ'[j-=1]}