Solve AOJ2242