Brute force derangement implementation
Derangement implementation from paper