N,M=map(int,input().split()) use=[False]*(N+1) ans=[] for i in range(M): u,v=map(int,input().split()) if (not use[u]) and (not use[v]): use[u]=True use[v]=True ans.append(i+1) print(len(ans)) print(*ans,sep='\n')