N,Q=map(int,input().split()) A=list(map(int,input().split())) result=[0]*Q q=[] for i in range(Q): pos,x,l,r=map(int,input().split()) q.append((pos,x,l,r)) for pos in range(1,N+1): y=A[pos-1] now=pos for i in range(Q): pos,x,l,r=q[i][:] if pos