n,m = map(int,input().split())
roads1 = []
roads2 = []
rez = ""
way = []
for i in range(0,m,1):
    first, second = map(str,input().split())
    roads1.append(first)
    roads2.append(second)
for i in range(1,6,1):
    if (roads1.count(i)+roads2.count(i))==1:
        rez = "NO"
print(rez)
if rez!="NO":
    for i in range(0,n+1,1):
        if len(way)==0:
            way.append(roads1[i])
            way.append(roads2[i])
            while len(way)<n+1:
                ind = roads1.index(way[-1])
                way.append(roads2[ind])
            print(way)
            for j in range(1,n+1,1):
                if len(way)!=0:
                    if (way.count(j)==0) or (way.count(j)>=3):
                        way=[]
            print(way)
    '''if len(way)!=0:
        rez = "YES"
        print(rez)
        print('\n'.join(way))
    else:
        print("NO")'''