#include<bits/stdc++.h>
using namespace std;
int link[100005]={},l=0;
bool b[100005]={};
struct edge
{
int y,nxt;
} e[200005];
int dfs(int x)
{
int maxn=0;
maxn=max(maxn,x);
b[x]=1;
int p=0;
for(p=link[x];p;p=e[p].nxt)
{
if(!b[e[p].y])
maxn=max(maxn,dfs(e[p].y));
}
return maxn;
}
int main()
{
int n=0,m=0,i=0,u=0,v=0;
cin>>n>>m;
for(i=1;i<=m;i++)
{
cin>>u>>v;
l++;
e[l].nxt=link[u];
e[l].y=v;
link[u]=l;
}
for(i=1;i<=n;i++)
{
memset(b,0,sizeof(b));
cout<<dfs(i)<<'\n';
}
}