solve AOJ2170