Committing solution for Ex.6