d to store the time each cell gets flooded, with a default value of -1 for all cells.q to perform BFS on the flooded cells, marking their flooding time in d.pq to perform a modified Dijkstra's algorithm starting from the cell containing 'S'.-1 to indicate the destination is unreachable.