import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static final int MOD = 1000000007; 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 (int i = 0; i < n; i++) { sb.append(pow(uft.getValue(i), MOD - 2)).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; int[] counts; long[] values; public UnionFindTree(int size) { parents = new int[size]; values = new long[size]; counts = new int[size]; for (int i = 0; i < size; i++) { parents[i] = i; counts[i] = 1; values[i] = 1; } } public int find(int x) { if (x == parents[x]) { return x; } else { int p = find(parents[x]); if (parents[x] != parents[parents[x]]) { values[x] *= values[parents[x]]; values[x] %= MOD; } return parents[x] = p; } } public boolean same(int x, int y) { return find(x) == find(y); } public void unite(int x, int y) { int xx = find(x); int yy = find(y); if (counts[xx] == counts[yy]) { values[yy] *= pow(values[xx], MOD - 2); values[yy] %= MOD; values[xx] *= 2; values[xx] %= MOD; counts[xx] += counts[yy]; parents[yy] = xx; } else if (counts[xx] < counts[yy]) { values[xx] = 0; counts[yy] += counts[xx]; parents[xx] = yy; } else { values[yy] = 0; counts[xx] += counts[yy]; parents[yy] = xx; } } public long getValue(int x) { find(x); if (x == parents[x]) { return values[x]; } else { return values[x] * values[parents[x]] % MOD; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); 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 int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }