use itertools library and add new query.hint function