import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
mod = 10 ** 9 + 7
inv = pow(2, mod - 2, mod)

class UnionFind():
    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)]
        self.st = [set([i]) for i in range(n)]
        self.ans = [1 for _ in range(n)]

    def find(self, 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 = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] == self.size[y]:
                for sx in self.st[x]:
                    self.ans[sx] *= inv
                    self.ans[sx] %= mod
                for sy in self.st[y]:
                    self.ans[sy] *= inv
                    self.ans[sy] %= mod                    
            elif self.size[x] < self.size[y]:
                for sx in self.st[x]:
                    self.ans[sx] = 0
                x, y = y, x
            else:
                for sy in self.st[y]:
                    self.ans[sy] = 0
                
                    
            self.par[y] = x
            self.size[x] += self.size[y]
            while self.st[y]:
                self.st[x].add(self.st[y].pop())                

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    
N, M = map(int, input().split())
U = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    U.union(a, b)
    
for a in U.ans:
    print(a)