implement substituting order brute-forcing