implement shortest and longest