import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
// 快输模板
class read{
StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws Exception{
st.nextToken();
return (int)st.nval;
}
}
public class Main {
static int N = 100010;
static int[] e = new int[N];
static int[] ne = new int[N];
static int[] h = new int[N];
static boolean[] st = new boolean[N];
static int idx = 0;
static int n,m;
static int max = 0;
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
static void dfs(int u){
if(max < u)
max = u;
st[u] = true;
for(int i = h[u];i != -1;i = ne[i]){
int j = e[i];
if(!st[j])
dfs(j);
}
}
static void add(int a,int b){
e[idx] = b;
ne[idx] = h[a];
h[a] = idx ++;
}
public static void main(String[] args) throws Exception {
read sc = new read();
n = sc.nextInt();
m = sc.nextInt();
Arrays.fill(h,-1);
while(m -- > 0){
int a = sc.nextInt();
int b = sc.nextInt();
add(a,b);
}
//直接暴搜所有点
for(int i = 1;i <= n;i ++){
max = 0;
Arrays.fill(st,0,n + 1,false);
dfs(i);
out.print(max + " ");
}
out.flush();
out.close();
}
}