AC solution: swap nodes in pairs