program speedrun
    use iso_fortran_env
implicit none
integer::N
integer(int64),allocatable,dimension(:)::A,B
integer(int64),allocatable,dimension(:)::A2,B2
integer,allocatable,dimension(:):: B2Table
integer::i,B2ind,A2ind
integer::k
integer(int64)::x
read*,N
allocate(B(0:N-1),A(0:N-1),B2(0:N),A2(0:2*N-2),B2Table(0:N))
read*,A(0:N-1)
read*,B(0:N-1)
do i=0,N-2
    B2(i)=xor(B(i),B(i+1))
end do
B2(N-1)=xor(B(N-1),B(0))
B2(N)=-1
do i=0,N-2
    A2(i)=xor(A(i),A(i+1))
    A2(i+N)=A2(i)
end do
A2(N-1)=xor(A(N-1),A(0))

B2ind=0;A2ind=0

call KMP_C_T(N,B2(0:N-1),B2Table(0:N-1))

do while(B2ind+A2ind <2*N-1 )
    do while(A2ind<2*N-1.and.B2ind<N)
        if(B2(B2ind)==A2(B2ind+A2ind))then
            B2ind=B2ind+1
        else
            A2ind=A2ind+B2ind-B2Table(B2ind)
            if(B2ind>0)B2ind=B2Table(B2ind)
        end if
    end do
    if(B2ind==N)then
        k=A2ind
        if(k>=N)exit
        x=xor(B(0),A(K))
        print"(i0,A,i0)",k," ",x
        A2ind=A2ind+B2ind-B2Table(B2ind)
        B2ind=B2Table(B2ind)
    endif
end do
contains
subroutine KMP_C_T(NN,AA,T)
    integer::NN
    integer(int64),intent(in)::AA(0:N)
    integer,intent(inout)::T(0:N)
    integer::ii,j
    ii = 2
    j = 0 
    T(0) = -1
    T(1) = 0

    do while (ii<=NN)
        if (AA(ii - 1) == AA(j))then
            T(ii) = j + 1
            ii = ii + 1
            j = j + 1
        else if (j > 0)then
            j = T(j)
        else
            T(ii) = 0
            ii = ii + 1
        endif
    end do
end subroutine
end program speedrun