class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索して親を出す。 """ if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): """ x と y のグループを結合 """ x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] def is_same(self, x, y): """ x と y が同じグループか否か """ return self.find(x) == self.find(y) def get_size(self, x): """ x が属するグループの要素数 """ x = self.find(x) return self.size[x] from collections import defaultdict N,M = map(int,input().split()); MOD = pow(10,9)+7 half = pow(2,MOD-2,MOD) A =[]; B =[] for _ in range(M): a,b = map(int,input().split()) a-=1;b-=1 #0-index A.append(a);B.append(b) uf = UnionFind(N) dic = defaultdict(set) ans = [1]*N for i in range(N): dic[i].add(i) zero = set([]) for i in range(M): a_par = uf.find(A[i]) b_par = uf.find(B[i]) if A[i] == B[i]: continue if uf.get_size(A[i]) > uf.get_size(B[i]): for b in dic[b_par]: ans[b] = 0 dic[a_par] = dic[a_par].union(dic[b_par]) elif uf.get_size(B[i]) > uf.get_size(A[i]): for a in dic[a_par]: ans[a] = 0 dic[b_par] = dic[b_par].union(dic[a_par]) else: #print(uf.get_size(A[i]),uf.get_size(B[i])) #print(dic[a_par],dic[b_par]) for x in dic[a_par]: ans[x] *= half; ans[x] %= MOD for x in dic[b_par]: ans[x] *= half; ans[x] %= MOD dic[a_par] = dic[a_par].union(dic[b_par]) dic[b_par] = dic[b_par].union(dic[a_par]) uf.union(A[i],B[i]) #print(dic) #print(A[i],B[i],ans) print(*ans,sep="\n")