open Batteries
let _ = read_line ()
let ys = read_line () |> String.split_on_char ' ' |> List.map int_of_string
let zs = read_line () |> String.split_on_char ' ' |> List.map int_of_string

let rec binary_search' xs v s e =
  if s > e then s
  else
    let m = (s+e)/2 in
    if xs.(m) >= v then binary_search' xs v s (m - 1)
    else binary_search' xs v (m + 1) e

let bsearch xs v = binary_search' xs v 0 (Array.length xs - 1)

let count_between xs s e = bsearch xs e - bsearch xs s

let f n =
  let m = Int.pow 2 (n+1) in
  let ys' = List.map (flip (mod) m) ys in
  let zs' = List.map (flip (mod) m) zs |> List.sort compare |> Array.of_list in
  let t = m / 2 in
  let g n = count_between zs' (t - n) (2*t - n) + count_between zs' (3*t - n) (4*t - n) in
  List.map g ys' |> List.fold_left (+) 0 |> flip (mod) 2

let ans =
  List.init 30 (fun i -> (f i) * (Int.pow 2 i))
  |> List.fold_left (+) 0
  |> string_of_int

let () = print_endline ans