Solve AOJ2012