fixed a bug. changed interface to align with AOJ.
added test pattern
align with AOJ interface.