First as already mentioned make sure the supply is off to the lighting circuit at east, you can co this by switching off the 5 amp circuit breakers, usually they have a white switch on them.
picture 2 is easier a the cable cores are clearly marked.
1. the cores with green/yellow sleeving is the earth, these should be clampede under the lage screw and washer towards the bottom of the picture. the 3 brown cores arejust left in the connector block joined together. the two blue cores and the blue core from the flex go into one side of the double connector block in the base of the light,N the blue core sleeved brown and the brown core in the flex go to the other, SWL,
the 1st picture is more difficult as the two cables are not marked.
the earth as before, the two blue cores one goes to one side of the double connector block inthe light fitting and the other one to the other side. the two brown cores need to be fixed together into a connector block as in picture 2.
hope you can do that.