Grab your multimeter and test for conductivity between the four wires -- it should be obvious that there are two pairs.
One pair goes to M1, the other to M2. Run the test sketch and you have a 50/50 chance it will work. If the motor just jiggles then you need to flip one of the pairs.