#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; VVI to(n + m); VI r(n); iota(all(r), 0); set roots; rep(i, n) roots.insert(i); dsu d(n); rep(im, m) { int a, b; cin >> a >> b; a = d.leader(a - 1), b = d.leader(b - 1); if (a == b) continue; int sza = d.size(a), szb = d.size(b); if (sza < szb) swap(a, b); d.merge(a, b); int ra = r[a], rb = r[b]; r[a] = n + im; roots.erase(ra), roots.erase(rb); roots.insert(n + im); to[n + im].push_back(ra); if (sza == szb) { to[n + im].push_back(rb); } } mint inv2 = mint(1) / 2; vector ans(n); for(int s: roots) { auto dfs = [&](auto&& self, int u, mint p) { if (u < n) { ans[u] = p; return; } if (to[u].size() == 2) p *= inv2; for(int v: to[u]) self(self, v, p); }; dfs(dfs, s, 1); } rep(i, n) cout << ans[i].val() << '\n'; }