Https://cses.fi/problemset/task/1746

Can anyone tell how this problem can be converted into paths and grids solvable?