package javaapplication1;
import java.util.Scanner;
public class JavaApplication1 {
    public static void main(String[] args) {
        //definise se skaner
        Scanner ulaz = new Scanner(System.in);
        //velicina niza
        int n = ulaz.nextInt();
        //prvi niz
        int[] a = new int[n];
        //drugi niz
        int[] b = new int[n];
        for(int i = 0; i<n;i++) {
            a[i]=ulaz.nextInt();
        }
        for(int i = 0; i<n;i++) {
            b[i]=ulaz.nextInt();
        }
        int max=0;
        for(int l =0 ; l<n;l++) {
            int xor=0, and=Integer.MAX_VALUE;;
            for(int r=l;r<n;r++) {
                xor ^= a[r];
                and &= b[r];
                
                int c = xor * and;
                
                if (c > max) {
                    max = c;
                }
            }
        }
        System.out.println(max);
}
}