How Toffoli gate works?