In the first test case, one of the shortest escape routes goes as follows: $5$ (initial) $\rightarrow$ $3$ (pick up key $1$) $\rightarrow$ $7$ (unlock grate~$1$) $\rightarrow$ $9$ (pick up key $4$) $\rightarrow$ $1$ (unlock grate $4$) $\rightarrow$ $-1$ (pick up key $3$) $\rightarrow$ $2$ (pick up key $5$) $\rightarrow$ $10$ (unlock grate~$5$) $\rightarrow$ $11$ (unlock grate $3$) $\rightarrow$ $13$ (hatch).
