Solve 039 and 040