MOD = 10 ** 9 + 7 n, m = map(int, input().split()) leader = [[i] for i in range(n)] parent = [-1] * n ans = [1] * n inv = pow(2, MOD - 2, MOD) def find(x): if parent[x] < 0: return x parent[x] = find(parent[x]) return parent[x] def unite(x, y): x = find(x) y = find(y) if x == y: return if parent[x] > parent[y]: leader[x], leader[y] = leader[y], leader[x] x, y = y, x if parent[x] == parent[y]: for i in leader[y]: leader[x].append(i) for i in leader[x]: ans[i] *= inv ans[i] %= MOD else: for i in leader[y]: ans[i] = 0 parent[x] += parent[y] parent[y] = x for _ in range(m): a, b = map(int, input().split()) unite(a - 1, b - 1) print(*ans, sep="\n")