GolfScript, 9494 93 characters
[{}/8,{97+.3$-.*:>8,{49+.4$-.*:^2$+.[3<>^*4=>^=>^*!.2$|]"KNBRQ"8$?=*{[5$3$@]""+p}{;}if}/;;}/];
Commented and nicer sourceCommented and nicer source:
[
{}/ # tIn fIn rIn
8,{97+ # fTst
.3$-.*:> # fDif^2 : >
8,{49+ # rTst
.4$-.*:^ # rDif^2 : ^
2$+. # ^>+
[3< # These # [validK
>^*4= # checks # validN
>^= # do not # validB
>^*! # account # validR
.2$|] # for null # validQ]
"KNBRQ"8$?= # move; # valid
* # * does. # validNotNull
{[5$3$@]""+p}{;}if # print? # fDif^2
}/;; # rIn
}/];