Help in Minimum Path in a grid (DP) (Codechef- FFC320G)

Problem: Minimum Path (Problem Code FFC320G)
How do I use the classic dp problem of minimum sum in grid to print the lexicographically smallest path?
My approach: I first calculated the dp table for entire grid, then made a path from (N,N) to (1,1) at each step remembering the choice, Checking if going up or left gives same value or not. If it does not, choose char of min one, else greedily choose smaller char and explore that.
I found my logic to be flawed, realized can’t greedily do so. Maybe I could use a DFS, but I don’t know how would I use the dp table to choose paths in DFS.
Please share your logic/solution how you would go on to solve this problem!