Let's take for example
It's congruent to
Now, you know by Fermat's little theorem, that
As you noticed,
It can be proved that hence
Why ? Because
I finally got it to work out using TheAbstractionist's method (I looked at what you did, did it for 2222 whilst looking at yours and then did it for 5555 separately).
I'll have a go using your method now Moo since it seems to be the one in the mark scheme.