local mmi = math.min
local tins = table.insert
local rshift = bit.rshift
local n = io.read("*n", "*l")
local a, b = {}, {}
local av, bv = {}, {}
local alt_a, alt_b = {}, {}
local alt_av, alt_bv = {}, {}
do
  local str = io.read()
  for v in str:gmatch("%d+") do
    tins(a, tonumber(v))
  end
  str = io.read()
  for v in str:gmatch("%d+") do
    tins(b, tonumber(v))
  end
end
for i = 1, n do
  av[i], bv[i] = 0, 0
  alt_a[i], alt_b[i] = 0, 0
  alt_av[i], alt_bv[i] = 0, 0
end
local mul = 1
local ret = 0
for _state = 1, 29 do
  local a_src = _state % 2 == 1 and a or alt_a
  local av_src = _state % 2 == 1 and av or alt_av
  local a_dst = _state % 2 == 0 and a or alt_a
  local av_dst = _state % 2 == 0 and av or alt_av
  local b_src = _state % 2 == 1 and b or alt_b
  local bv_src = _state % 2 == 1 and bv or alt_bv
  local b_dst = _state % 2 == 0 and b or alt_b
  local bv_dst = _state % 2 == 0 and bv or alt_bv
  local a0c, b0c = 0, 0
  for i = 1, n do
    if a_src[i] % 2 == 0 then a0c = a0c + 1 end
    if b_src[i] % 2 == 0 then b0c = b0c + 1 end
  end
  local cur_a0, cur_b0, cur_a1, cur_b1 = 0, 0, 0, 0
  for i = 1, n do
    if a_src[i] % 2 == 0 then
      cur_a0 = cur_a0 + 1
      a_dst[cur_a0] = rshift(a_src[i], 1)
      av_dst[cur_a0] = av_src[i]
    else
      cur_a1 = cur_a1 + 1
      a_dst[a0c + cur_a1] = rshift(a_src[i], 1)
      av_dst[a0c + cur_a1] = av_src[i] + mul
    end
    if b_src[i] % 2 == 0 then
      cur_b0 = cur_b0 + 1
      b_dst[cur_b0] = rshift(b_src[i], 1)
      bv_dst[cur_b0] = bv_src[i]
    else
      cur_b1 = cur_b1 + 1
      b_dst[b0c + cur_b1] = rshift(b_src[i], 1)
      bv_dst[b0c + cur_b1] = bv_src[i] + mul
    end
  end

  local bp1, bp2, bp3 = n + 1, n + 1, n + 1
  local c1 = n * (n + 1)
  local c2, c3 = c1, c1
  for i = 1, n do
    local iav = av_dst[i]
    local bp3lim = mmi(n, bp3)
    for ib = bp3lim, 1, -1 do
      if mul * 3 <= bv_dst[ib] + iav then
        bp3 = ib
      else break end
    end
    local bp2lim = mmi(n, mmi(bp2, bp3))
    for ib = bp2lim, 1, -1 do
      if mul * 2 <= bv_dst[ib] + iav then
        bp2 = ib
      else break end
    end
    local bp1lim = mmi(n, mmi(bp1, bp2))
    for ib = bp1lim, 1, -1 do
      if mul <= bv_dst[ib] + iav then
        bp1 = ib
      else break end
    end
    c3 = c3 - bp3
    c2 = c2 - bp2
    c1 = c1 - bp1
  end
  if (c1 - c2 + c3) % 2 == 1 then
    ret = ret + mul
  end
  mul = mul * 2
end
print(ret)
