import sys input = sys.stdin.readline from collections import deque N,M=map(int,input().split()) E=[[] for i in range(N)] for i in range(M): x,y=map(int,input().split()) x-=1 y-=1 E[x].append(y) E[y].append(x) Q=deque() Q.append(0) DIS=[1<<30]*N DIS[0]=0 while Q: x=Q.popleft() for to in E[x]: if DIS[to]>DIS[x]+1: DIS[to]=DIS[x]+1 Q.append(to) ANS=[0]*(N+1) for d in DIS: if d