Solved AOJ 0582