#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

pub trait BinarySearch<T> {
    fn lower_bound_by_key<B: Ord, F: FnMut(&T) -> B>(&self, x: &B, mut f: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize;
}


impl<T: Ord + Clone> BinarySearch<T> for Vec<T> {
    fn lower_bound(&self, x: &T) -> usize {
        self.lower_bound_by_key(x, |y| y.clone())
    }

    fn lower_bound_by_key<B: Ord, F: FnMut(&T) -> B>(&self, x: &B, mut f: F) -> usize {
        let mut high = self.len();
        let mut low = 0;
        while low < high {
            let mid = (low + high) / 2;
            if  f(&self[mid]).lt(&x) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }
}

fn _solve(k: u32, a: u32, bb: &Vec<u32>) -> u32 {
    let mask = (1 << (k+1)) - 1;
    let a = a & mask;
    let t = 1 << k;

    let p1 = bb.lower_bound_by_key(&t, |b| (a & mask) + (b & mask));
    let p2 = bb.lower_bound_by_key(&(2*t), |b| (a & mask) + (b & mask));
    let p3 = bb.lower_bound_by_key(&(3*t), |b| (a & mask) + (b & mask));

    if ((bb.len() - p3) + (p2 - p1)) % 2 == 1 {
        t
    } else {
        0
    }
}

fn solve(aa: Vec<u32>, mut bb: Vec<u32>) -> u32 {
    let mut ans = 0;
    let mut mask = 0;
    for i in 0..29 {
        let mask = (1 << (i+1)) - 1;
        bb.sort_by_key(|x| x & mask);

        for a in aa.iter() {
            ans = ans ^ _solve(i, *a, &mut bb);
        }
    }
    ans
}

fn main() {
    read_line!();
    let aa = parse_vec!(u32);
    let bb = parse_vec!(u32);

    println!("{}", solve(aa, bb));
}

#[test]
fn solve_test() {
    assert_eq!(_solve(0, 0, &mut vec![1, 1, 1]), 1);
    assert_eq!(_solve(0, 0, &mut vec![1, 1, 1, 1]), 0);
    assert_eq!(_solve(0, 1, &mut vec![1, 1, 1, 1]), 0);

    assert_eq!(_solve(1, 1, &mut vec![0b11]), 0);
    assert_eq!(_solve(1, 1, &mut vec![0b01, 0b11]), 0b10);

    assert_eq!(solve(vec![1, 2], vec![3, 4]), 2);
    assert_eq!(solve(vec![4, 6, 0, 0, 3, 3], vec![0, 5, 6, 5, 0, 3]), 8);
    assert_eq!(solve(vec![1, 2, 3, 4, 5], vec![1, 2, 3, 4, 5]), 2);
    assert_eq!(solve(vec![0], vec![0]), 0);
}


Measured memory_bytes: 11508