[NBF] added the reversing-pair algorithm