Definitely sounds like your firing order is out, especially if it ran before you took it apart. I would be checking the firing order, as I assume you don’t have a picture before you took the wires out. Usually a firing order will be stamped somewhere on the block or intake. A manual may be required. I thought Mazda engines were timed from the front to the back. 1,3,4,2 and #1 was front left.