{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.Bits             (shiftL, (.&.))
import qualified Data.ByteString.Char8 as BC
import           Data.List             (sort)
import           Data.Maybe            (fromJust)
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  n <- readLn
  as <- getInts
  bs <- getInts
  print $ solve n as bs

solve :: Int -> [Int] -> [Int] -> Int
solve n as bs = sum $ map kXorBit [0 .. 28] where
  kXorBit k = if odd s then t else 0 where
    t = 1 `shiftL` k
    t2 = 1 `shiftL` (k + 1)
    cs = V.fromList . sort $ map (`mod` t2) bs
    s = sum $ map count as
    count a = (t12 - t01) + (n - t23) where
      t01 = binarySearch cs $ t - a'
      t12 = binarySearch cs $ t2 - a'
      t23 = binarySearch cs $ 3 * t - a'
      a' = a `mod` t2

binarySearch :: V.Vector Int -> Int -> Int
binarySearch xs y = go 0 $ V.length xs where
  go l r
    | l == r = l
    | x < y = go (m + 1) r
    | x >= y = go l m
    where m = (r + l) `div` 2
          x = xs V.! m

odd' :: Int -> Bool
odd' n = n .&. 1 == 1

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

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