N=io.read"*n"
M=io.read"*n"
t={}
for i=1,N do t[i]={}end
for i=1,M do
	local A=io.read"*n"
	local B=io.read"*n"
	table.insert(t[A],B)
	table.insert(t[B],A)
end

u={[1]=0}
local function f(x)
	for i,v in ipairs(t[x])do
		if(u[v]==nil)then
			u[v]=i
			f(v)
		end
	end
end
f(1)
for i=2,N do
	if(u[i]==nil)then
		print"No"
		return
	end
end
print"Yes"
for i=2,N do
	print(u[i])
end