Solves problem #1.