Hello,

For the first one, I can't really see any simple method.

5²=25, 5^4=25^2=625

77x2=154 and since 600=4x150, 77x8=154x4=600+16=-9 mod 625

and 154=155-1=5x31-1 -> 5x31=1 mod 77.

So finally 5^7=(5^4)^2 * 31 mod 77 = 81*31 mod 77 = 4x31 mod 77 = 124 mod 77 = -30 mod 77.

As for the second one, it looks awful (even the first one was awful)... in which chapter was it ? what's the context ? it looks like some cipher stuff.