An alternative approach could be to have n images, and know which are the pairs by displaying each image twice in the grid. That way, you can take the images away when a pair is made, and not rely on user actions.
Nice application idea for kids.
I made a mistake in my instructions as I said that we have to use 70 images. We need to use 35 images. Thanks for pointing this mistake. I have updated my sets of instructions.