Lookout for last digit :
3^1=3
3^2 =9
3^3 =7
3^4 =1
3^5 =3
and the sequence is : 3,9,7,1,3,9,7,1……………………………
at 3^51 it would be at 7. (you can see here for every multiple of 4 we are getting 1 as a last digit. so at 48 it would be “1” , at 49 it would be 3 , at 50 it would be 9 and at 51 it would be 7.)
xxxxxx7 mod 5 is as same as 7 mod 5 = 2.