solves problem1