local n, m = io.read("*n", "*n")
local edge = {}
for i = 1, n do
  edge[i] = {}
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  edge[a][b], edge[b][a] = true, true
end

local len = {}
local ret = {}
local inf = 1000000007
for i = 1, n do
  len[i] = inf
  ret[i] = 0
end
len[1] = 0

local tasks = {1}
for i = 1, n do
  local src = tasks[i]
  -- print(src)
  -- print(len[src])
  for dst, _u in pairs(edge[src]) do
    -- print(src .. " to " .. dst)
    if len[dst] + 1 == len[src] then
      ret[src] = dst
    elseif len[dst] == inf then
      len[dst] = len[src] + 1
      -- print("INS", dst)
      table.insert(tasks, dst)
    end
  end
end
print("Yes")
for i = 2, n do
  print(ret[i])
end
