local mmi = math.min
local tins = table.insert
local n = io.read("*n", "*l")
local a, b = {}, {}
local av, 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
end
local mul = 1
local ret = 0
local rshift = bit.rshift
for _stage = 1, 29 do
  local a0, a1, a0v, a1v = {}, {}, {}, {}
  local b0, b1, b0v, b1v = {}, {}, {}, {}
  for i = 1, n do
    if a[i] % 2 == 0 then
      tins(a0, rshift(a[i], 1))
      tins(a0v, av[i])
    else
      tins(a1, rshift(a[i], 1))
      tins(a1v, av[i] + mul)
    end
    if b[i] % 2 == 0 then
      tins(b0, rshift(b[i], 1))
      tins(b0v, bv[i])
    else
      tins(b1, rshift(b[i], 1))
      tins(b1v, bv[i] + mul)
    end
  end
  local a0c, b0c = #a0, #b0
  for i = 1, a0c do a[i], av[i] = a0[i], a0v[i] end
  for i = 1, #a1 do a[i + a0c], av[i + a0c] = a1[i], a1v[i] end
  for i = 1, b0c do b[i], bv[i] = b0[i], b0v[i] end
  for i = 1, #b1 do b[i + b0c], bv[i + b0c] = b1[i], b1v[i] 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[i]
    local bp3lim = mmi(n, bp3)
    for ib = bp3lim, 1, -1 do
      if mul * 3 <= bv[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[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[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)
