{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main
where

import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Array
import           Data.Bits
import qualified Data.ByteString.Char8       as BC
import           Data.List
import           Data.Maybe
import           Data.STRef
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
    n <- readLn :: IO Int
    {-as <- map (read :: String -> Word) . words <$> getLine
    bs <- map (read :: String -> Word) . words <$> getLine-}
    as <- getInts
    bs <- getInts
    --print $ (build 0 bs) `seq` 0
    --print $ foldr1 xor $ zipWith ($) ((\k -> eachFigure k as) <$> [0..]) (build 0 bs)
    print $ sum $ eachFigure' as bs <$> [0..28]

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine

upperBoundImpl :: Int -> (Int, Int) -> VU.Vector Int -> Int
upperBoundImpl key (l, r) f =
    let mid = (l + r) `unsafeShiftR` 1
    in  if r - l <= 1 then r else
        if f `VU.unsafeIndex` mid <= key
            then upperBoundImpl key (mid, r) f
            else upperBoundImpl key (l, mid) f

upperBound :: Int -> (Int, Int) -> VU.Vector Int -> Int
upperBound key (l, r) = upperBoundImpl key (l - 1, r)

unsafeBit = (1 `unsafeShiftL`)

xorOnFigure :: VU.Vector Int -> Int -> Int -> Int
xorOnFigure sorted k a =
    let n = VU.length sorted
        notCarriers = upperBound (unsafeBit (k + 1) - 1 - a) (0, n) sorted
        i = upperBound (unsafeBit k - 1 - a) (0, n) sorted
        j = upperBound (unsafeBit k * 3 - 1 - a) (0, n) sorted
        --notCarriers = binarySearch sorted $ unsafeBit (k + 1) - a
        --i = binarySearch sorted $ unsafeBit k - a
        --j = binarySearch sorted $ unsafeBit (k + 1) + unsafeBit k - a
    in  (notCarriers - i) + (n - j)

eachFigure' :: [Int] -> [Int] -> Int -> Int
eachFigure' as bs k =
    let v = sort' $ VU.map (.&. (unsafeBit (k + 1) - 1)) $ VU.fromList bs
    in  if odd $ sum $ map (xorOnFigure v k) $ (.&. (unsafeBit (k + 1) - 1)) <$> as
        then unsafeBit k
        else 0

sort' :: VU.Vector Int -> VU.Vector Int
sort' = VU.modify (\v -> quicksort v 0 (VUM.length v))

-- https://github.com/as-capabl/haskell-qsort-pfm/blob/master/src/UV.hs
type IndType = Int

quicksort :: VUM.STVector s Int -> IndType -> IndType -> ST s ()
quicksort work iStart iEnd
    | iEnd - iStart <= 1 = return ()
    | otherwise =
        do
        pivot <- VUM.unsafeRead work ((iEnd + iStart) `shiftR` 1)
        med <- divide pivot iStart (iEnd - 1)
        quicksort work iStart med
        quicksort work med iEnd
    where
    divide pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise =
            do
            lower <- shrinkLower pivot iS' iE'
            higher <- shrinkHigher pivot lower iE'
            if lower >= higher
                then return lower
                else do
                swapWork lower higher
                divide pivot (lower + 1) (higher - 1)

    shrinkLower pivot iS' iE'
        | iS' > iE' = return iS'
        | otherwise =
            do
            x <- VUM.unsafeRead work iS'
            if x >= pivot
                then
                return iS'
                else
                shrinkLower pivot (iS' + 1) iE'

    shrinkHigher pivot iS' iE'
        | iS' > iE' = return iE'
        | otherwise =
            do
            x <- VUM.unsafeRead work iE'
            if x <= pivot
                then
                return iE'
                else
                shrinkHigher pivot iS' (iE' - 1)

    swapWork = VUM.unsafeSwap work
