#include using namespace std; const long long MOD = 1000000007; int main(){ int N, M; cin >> N >> M; vector ans(N, 1); vector p(N); vector> c(N); vector sz(N); for (int i = 0; i < N; i++){ p[i] = i; c[i].push_back(i); sz[i] = 1; } for (int i = 0; i < M; i++){ int a, b; cin >> a >> b; a--; b--; a = p[a]; b = p[b]; if (a != b){ if (sz[a] > sz[b]){ swap(a, b); } if (sz[a] < sz[b]){ for (int x : c[a]){ p[x] = b; c[b].push_back(x); ans[x] = 0; } sz[b] += sz[a]; sz[a] = 0; c[a].clear(); } else { for (int x : c[a]){ ans[x] *= 500000004; ans[x] %= MOD; } for (int x : c[b]){ p[x] = a; c[a].push_back(x); ans[x] *= 500000004; ans[x] %= MOD; } sz[a] += sz[b]; sz[b] = 0; c[b].clear(); } } } for (int i = 0; i < N; i++){ cout << ans[i] << endl; } }