Task 3.17

it checks for already used pairs