The white e-pawn captured the original a8-rook, and the knight,
towards c6. Then both the a- and h-pawn promoted. This can either go
via Bc8->b3; axb3; a1=Q/R; R/Qa1-g3; hxg3; h1=R; R->a8, or via Bc8->b3;
Q->g3; a1=R/Q; h1=Q/R; R->a8; Q->d5. In both cases, black can castle
kingside, not queenside, and white can't castle at all, because both
rooks had to move to allow the black promotions. So h#1 with 1. OO Qg7#.
The white e-pawn captured the original h8-rook, and the knight,
towards c6. Then the whole story in the previous case is the same, except
that black can only castle queenside, and white can't at all. So h#1
with 1. OOO Qc7#.
The white e-pawn captured on the f-line, and promoted on f8. Prior
to the capture on the f-line, white sacrificed a piece on c6. This requires
in total 4 promotions, so either the h- or the a-pawn promoted. If the
h-pawn promoted, white can't castle kingside, but he can still castle
queenside, because the a-pawn doesn't have to promote now. So h#1 with
1. OOO Ra1#.
Or the a-pawn promoted, breaking white's queenside castling, and
the h-pawn didn't promote. So h#1 with 1. OO Qg2#.
So all four castlings are legal, but they're not legal at the same
time!