Solution for the second lab at "Introduction to Theoretical Computer Science" course