
room,path = map(int,input().split())
dic = {}
ans_dic = {}
g = [1]
g_m = []

def re(li,i):
    if li[0] == i:
        return li[1]
    else:
        return li[0]

def pile_del(g):
    t = []
    for key,i in dic.items():
        if i[0] in g and  i[1] in g:
            t.append(key)
    for i in t:
        dic.pop(i)
    return 0

def main(ans_dic,dic,k):
    dele = []
    for key,j in dic.items():
        if k in j :
            ans_dic[re(j,k)] = j
            dele.append(key)
            g.append(re(j,k))
            g_m.append(re(j,k))
    for i in dele:
        dic.pop(i)
    pile_del(g_m)

for i in range(path):
    dic[i+1] = list(map(int,input().split()))

for key,i in dic.items():
    if 1 in i :
        if i[0] == 1:
            g.append(re(i,i[0]))
            # g_m.append(re(i,i[0]))
            ans_dic[i[1]] = i
        else:
            g.append(re(i,i[1]))
            # g_m.append(re(i,i[1]))
            ans_dic[i[0]] = i

pile_del(g)

li_c = len(dic)

if li_c != 0:
    for k in g:
        main(ans_dic,dic,k)

while li_c != len(dic) and li_c != 0:
    li_c = len(dic)
    for k in g:
        main(ans_dic,dic,k)



if len(ans_dic) == room-1:
    print("Yes")
    for i in range(room-1):
        print(re(ans_dic[i+2],i+2))
else:
    print("No")
# print(ans_dic)