let rec for_iter a b f = if a >= b then [] else let t = f a in t :: for_iter (a+1) b f

let lower_bound arr p =
  let rec f l r =
    if l >= r then r
    else
      let m = (l+r) / 2 in
      if p arr.(m) then f l m else f (m+1) r in
  f 0 (Array.length arr)

let () =
  Scanf.scanf "%d" (fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let b = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  Array.sort (-) a;
  for_iter 0 30 (fun i ->
    let m, mm = 1 lsl i, 2 lsl i in
    let bm = Array.map (fun v -> v mod mm) b in
    Array.sort (-) bm;
    a |> Array.map (fun x ->
      let xm = x mod mm in
      let i1 = lower_bound bm (let c = 1 * m - xm in fun e -> e >= c) in
      let i2 = lower_bound bm (let c = 2 * m - xm in fun e -> e >= c) in
      let i3 = lower_bound bm (let c = 3 * m - xm in fun e -> e >= c) in
      let i4 = lower_bound bm (let c = 4 * m - xm in fun e -> e >= c) in
      (i2-i1) + (i4-i3))
    |> Array.fold_left (+) 0
    |> (fun s -> (s mod 2) lsl i))
  |> List.fold_left (+) 0) |> Printf.printf "%d\n"
