n,m=map(int,input().split()) r=[-1]*n v=[[i] for i in range(n)] p=[1]*n M=10**9+7 i2=pow(2,M-2,M) def root(a): while r[a]!=-1: a=r[a] return a def union(a,b): a=root(a) b=root(b) if a==b: return if len(v[a])len(v[b]): for i in v[b]: p[i]=0 if len(v[a])==len(v[b]): for i in v[a]+v[b]: p[i]*=i2 p[i]%=M v[a]+=v[b] r[b]=a return for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 union(a,b) print(*p,sep="\n")