#include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ull M = 1000000007; const ull inv2 = M/2+1; struct DSU{ vector V; vector Z; vector P; vector iP; DSU(int n=0){ V.assign(n,-1); Z.assign(n,1); P.assign(n,1); iP.assign(n,1); } pair leader(int a){ if(V[a]>=0){ auto r=leader(V[a]); V[a]=r.first; P[a]=P[a]*r.second%M; return {V[a],P[a]}; } return {a,1}; } ull value(int a){ auto ap = leader(a); return ap.second * P[ap.first] % M; } void merge(int u,int v){ auto up = leader(u); u=up.first; auto vp = leader(v); v=vp.first; if(Z[u]Z[v]){ P[v]=0; iP[v]=0; V[v]=u; Z[u]+=Z[v]; } else{ P[v]=P[v]*iP[u]%M; iP[v]=iP[v]*P[u]%M; P[u]=P[u]*inv2%M; iP[u]=iP[u]*2%M; V[v]=u; Z[u]+=Z[v]; } } }; int N,Q; DSU dsu; int main(){ scanf("%d%d",&N,&Q); dsu = DSU(N); rep(i,Q){ int u,v; scanf("%d%d",&u,&v); u--; v--; dsu.merge(u,v); } rep(i,N) printf("%llu\n",dsu.value(i)); return 0; }