P05 solution (reverse)