This situation should be pointed out by the instructor in charge on the spot. If he did not point it out, he is also responsible. Therefore, your results should not be invalidated because of this, but should be treated as valid. After all, you passed the exam and signed the exam paper, but it was in the wrong place. You should have passed the exam.