Shortest path of the king

Problem Name:
Shortest path of the king
Site:CodeForces
Links:
Tags:
Problem setters: