R=range J=lambda:map(int,input().split()) N=J() U=J() T=J() f=1 for t in T:f|=f<