N,M=map(int,input().split()) x=[None]*N for _ in range(M): p,q,a,b=map(int,input().split()) p-=1 q-=1 x[p]=a x[q]=b print(*x)