#include <queue>
#include <bitset>
#include <iostream>
using namespace std;
const int N = 30010;
int head[N], ver[N], nxt[N], tot;
int n, m;
int deg[N], a[N], cnt;
bitset<N> f[N];
void add(int x, int y) {
ver[++tot] = y, nxt[tot] = head[x], head[x] = tot;
deg[y]++;
}
void topsort() {
queue<int> q;
for (int i = 1; i <= n; i++)
if (!deg[i]) q.push(i);
while (q.size()) {
int x = q.front(); q.pop();
a[++cnt] = x;
for (int i = head[x]; i; i = nxt[i]) {
int y = ver[i];
if (--deg[y] == 0) q.push(y);
}
}
}
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
int x, y; cin >> x >> y;
add(x, y);
}
topsort();
for (int i = cnt; i > 0; i--) {
int t = a[i];
f[t][t] = 1;
for (int x = head[t]; x; x = nxt[x])
f[t] |= f[ver[x]];
}
for (int i = 1; i <= cnt; i++) cout << f[i].count() << endl;
return 0;
}