This puzzle was created as a response to a challenge issued by the puzzle constructor known pseudonymously as Gliperal.
Doppelganger: Crypto Japanese Cave
Rules:
Place the numbers from 1 to 9 into some cells such that no number repeats in a row or column.
Clues outside the grid indicate the sums of connected groups of numbers in the respective row or column, in order, where empty cells serve as delimiters between groups.
The letters from GLIPERAX replace numbers from 0 to 9, and no two letters may replace the same number. A question mark can be any number from 0 to 9, and for all clues, none may have a leading zero. A pound sign indicates any positive integer.
The puzzle is to be solved two times. The first time, all the numbers are orthogonally connected, and all orthogonally connected groups of empty cells touch the perimeter of the grid. The second time, all the empty cells are orthogonally connected, and all orthogonally connected groups of numbers touch the perimeter of the grid.