import java.io.*; import java.util.*; public class Main { public static final int MOD = 1000000007; public static final long BY = pow(2, MOD - 2); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); UnionFindTree uft = new UnionFindTree(n); for (int i = 0; i < m; i++) { uft.unite(sc.nextInt() - 1, sc.nextInt() - 1); } StringBuilder sb = new StringBuilder(); for (long x : uft.pre) { sb.append(x).append("\n"); } System.out.print(sb); } static long pow(long x, int p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } static class UnionFindTree { int[] parents; ArrayList> member = new ArrayList<>(); long[] pre; public UnionFindTree(int size) { parents = new int[size]; pre = new long[size]; for (int i = 0; i < size; i++) { parents[i] = i; pre[i] = 1; member.add(new HashSet<>()); member.get(i).add(i); } } public int find(int x) { if (x == parents[x]) { return x; } else { return parents[x] = find(parents[x]); } } public void unite(int x, int y) { int xx = parents[x]; int yy = parents[y]; if (xx == yy) { return; } if (member.get(xx).size() == member.get(yy).size()) { member.get(xx).addAll(member.get(yy)); parents[yy] = xx; for (int z : member.get(xx)) { pre[z] *= BY; pre[z] %= MOD; } } else if (member.get(xx).size() < member.get(yy).size()) { for (int z : member.get(xx)) { pre[z] = 0; } member.get(yy).addAll(member.get(xx)); parents[xx] = yy; } else { for (int z : member.get(yy)) { pre[z] = 0; } member.get(xx).addAll(member.get(xx)); parents[yy] = xx; } } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }