The algorithm is not recognizing invalid cuboids :(