How can I implement this?

Hello,

I am doing a project which consists of having 9 cubes that form a puzzle. When a cube is positioned correctly it emits a green light, otherwise a red light. How can it be possible for a specific cube to know whether or not is in the right position?
p.s I'm a beginner in Arduino.

Thank you in advance!

Can you add connectors to the cubes? And when you place a cube, you actually push it in a connector of the opposite gender.

No I shouldn't use a connector. Also it is important that each cube knows with which side of the other cube is connected. One thought solutions is RFID tags but it is costly

I'm a beginner in Arduino.

Yet you choose an almost impossible project.

Magnets?