First and last appearance

Sign in to test your solution.