Implementing exhaustive search