#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair>; const ll INF = (1LL << 61); ll mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) :x((x%mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; istream& operator>>(istream& is, mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } struct UnionFind { vectorpar, vsize, esize; UnionFind(int sz_) : par(sz_), vsize(sz_, 1), esize(sz_, 0) { for (int i = 0; i < sz_; i++)par[i] = i; } void init(int sz_) { par.resize(sz_); vsize.resize(sz_, 1); esize.resize(sz_, 0); for (int i = 0; i < sz_; i++)par[i] = i; } int root(int x) { if (par[x] == x)return x; else return par[x] = root(par[x]); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) { esize[x]++; return false; } if (vsize[x] < vsize[y])swap(x, y); vsize[x] += vsize[y]; esize[x] += esize[y] + 1; par[y] = x; return true; } bool issame(int x, int y) { return root(x) == root(y); } int vs(int x) { return vsize[root(x)]; } int es(int x) { return esize[root(x)]; } }; vector>G; vectorseen; void dfs(int v) { seen[v] = true; for (auto nv : G[v]) { if (seen[nv])continue; dfs(nv); } } signed main() { ios::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; G.resize(N); seen.assign(N, false); UnionFind uf(N); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; a = uf.root(a), b = uf.root(b); int sa = uf.vs(a), sb = uf.vs(b); if (sa == sb) { } else if (sa < sb) { dfs(a); } else { dfs(b); } G[a].push_back(b); G[b].push_back(a); uf.merge(a, b); } vectorcnt(N); for (int i = 0; i < N; i++) { if (seen[i]) { cnt[uf.root(i)]++; } } for (int i = 0; i < N; i++) { int now = uf.vs(i); now -= cnt[uf.root(i)]; if (now == 0 || seen[i])cout << 0 << endl; else { mint ans = 1; ans /= now; cout << ans << endl; } } return 0; }