Solution for task 2.3.15 (Nuts and Bolts).