Solve AOJ2399