Ex-7. Tasks from 1 to 5 are implemented.