N, M = map(int, input().split())
MOD = 10 ** 9 + 7
i2 = pow(2, MOD - 2, MOD)
ans = [1] * N
st = [{i} for i in range(N)]
root = list(range(N))
for _ in range(M):
    a, b = (int(x) - 1 for x in input().split())
    ra = root[a]
    rb = root[b]
    if len(st[ra]) == len(st[rb]):
        for x in st[ra]:
            ans[x] *= i2
            ans[x] %= MOD
        for x in st[rb]:
            ans[x] *= i2
            ans[x] %= MOD
            root[x] = ra
    else:
        if len(st[ra]) < len(st[rb]):
            ra, rb = rb, ra
        for x in st[rb]:
            ans[x] = 0
            root[x] = ra
    st[ra] |= st[rb]
    st[rb] = {}
print(*ans, sep="\n")