Solutions to both problems