Bitwise solution.