package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	destinations := make([]*IntList, n+1)
	for i := 1; i <= n; i++ {
		destinations[i] = NewIntList()
	}
	for i := 0; i < m; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		destinations[b].Add(a)
		destinations[a].Add(b)
	}

	fmt.Println("Yes")

	nodes := make([]Node, n+1)
	for i := 1; i <= n; i++ {
		nodes[i].Number = i
	}
	nodes[1].RoomFrom = 1

	filledNodeCount := 1
	prevFilledNodes := NewNodeList()
	prevFilledNodes.Add(&nodes[1])
	for filledNodeCount < n {
		filledNodes := NewNodeList()
		prevFilledNodes.Each(func(nodeFrom *Node) {
			destinations[nodeFrom.Number].Each(func(nodeNumberTo int) {
				nodeTo := &nodes[nodeNumberTo]
				if nodeTo.RoomFrom != 0 {
					return
				}

				nodeTo.RoomFrom = nodeFrom.Number
				filledNodes.Add(nodeTo)
				filledNodeCount++
			})
		})
		prevFilledNodes = filledNodes
	}

	for i := 2; i <= n; i++ {
		fmt.Println(nodes[i].RoomFrom)
	}
}

type Node struct {
	Number   int
	RoomFrom int
}

type IntList struct {
	first *intListNode
	last  *intListNode
}

type intListNode struct {
	child *intListNode
	value int
}

func NewIntList() *IntList {
	root := intListNode{nil, 0}
	return &IntList{&root, &root}
}

func (list *IntList) Add(item int) {
	node := intListNode{nil, item}
	list.last.child = &node
	list.last = &node
}

func (list *IntList) Concat(other *IntList) {
	if other.first.child == nil {
		return
	}
	list.last.child = other.first.child
	list.last = other.last
}

func (list *IntList) Each(f func(item int)) {
	cur := list.first
	for cur.child != nil {
		cur = cur.child
		f(cur.value)
	}
}

type NodeList struct {
	first *nodeListNode
	last  *nodeListNode
}

type nodeListNode struct {
	child *nodeListNode
	value *Node
}

func NewNodeList() *NodeList {
	root := nodeListNode{nil, nil}
	return &NodeList{&root, &root}
}

func (list *NodeList) Add(item *Node) {
	node := nodeListNode{nil, item}
	list.last.child = &node
	list.last = &node
}

func (list *NodeList) Concat(other *NodeList) {
	if other.first.child == nil {
		return
	}
	list.last.child = other.first.child
	list.last = other.last
}

func (list *NodeList) Each(f func(item *Node)) {
	cur := list.first
	for cur.child != nil {
		cur = cur.child
		f(cur.value)
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 18280