#include<bits/stdc++.h>
#include<atcoder/all>
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<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    VVI alives(n);
    rep(i, n) alives[i].push_back(i);
    dsu d(n);
    rep(_, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        int la = d.leader(a), lb = d.leader(b);
        if (la == lb) continue;
        int sza = d.size(la), szb = d.size(lb);
        int lc = d.merge(la, lb);
        if (sza == szb) {
            // la <- lb
            for(int x: alives[lb]) alives[la].push_back(x);
        }
    }
    vector<mint> ans(n);
    rep(i, n) if (d.leader(i) == i) {
        mint p = 1 / mint::raw(alives[i].size());
        for(int x: alives[i]) ans[x] = p;
    }
    rep(i, n) cout << ans[i].val() << '\n';
}