Simple brute force solution with pruning based on reachable keys.