MOD = 10 ** 9 + 7 n, m = map(int, input().split()) inv2 = pow(2, MOD - 2, MOD) ans = [1 for _ in range(n)] grp = [[i] for i in range(n)] par = [i for i in range(n)] for _ in range(m): a, b = map(int, input().split()) a = par[a - 1] b = par[b - 1] if a != b: la = len(grp[a]) lb = len(grp[b]) if la > lb: la, lb = lb, la a, b = b, a if la == lb: while len(grp[a]) > 0: v = grp[a].pop() par[v] = b grp[b].append(v) for v in grp[b]: ans[v] = (ans[v] * inv2) % MOD else: while len(grp[a]) > 0: v = grp[a].pop() par[v] = b grp[b].append(v) ans[v] = 0 print(*ans, sep="\n")