(1) which method is working, which is not working and you are asking about it here? give me the mthod name.
(2) a suggestion, in IsLegal(), codes that determinate if JQK exists should be in the outer loop, there is not need to check them in the inner loop.