Yes they have to go back into the same place. If they are shim over or shimless buckets they are specifically so many thousandths for each positions requirements. If you mix them up you can be too tight or loose and bend valves break springs or not get valve seal and then you dont make compression.
Pull each one out individually as you go and clean it well with break clean, let it dry and write on the top with a sharpy where it came from.
If your puttign in new valves then you have to remeasure all the tolerances and size the buckets accordingly.