provided solution for 23-d problem