n=int(input())
m=int(input())
graf=[]
dgraf=[]
for i in range(n):
    l=[]
    graf.append(l)
    dgraf.append(0);
for i in range(m):
    s,c=map(int,input().split())
    graf[s].append(c)
    graf[c].append(s)
    dgraf[s]+=1
    dgraf[c]+=1
for i in range(n):
    graf[i].sort()
for i in range(n):
    for j in range(dgraf[i]):
        print(graf[i][j],end=' ')
    print()
