dynamic programming with kinematics passes all tests.