.
Answer. x = 1752.
Check. 40*1752 - 777 = 69303 = 39*1777.
How did I find it? - Using MS Excel in my computer.
and also knowing that 40x = 777 (mod 1777) means that the difference 40x - 777 is a multiple of 1777.
Solved.
============================
Dear "students" !
Today is a special day.
Today I solved 16 problems for you and got back 0 (zero, ZERO) "thanks" from you.
It is the absolute record !
It is just out of limits of my understanding !
I never saw it before !
Thank you very much and wish you to think: WHO ARE YOU . . .