/*
Copyright 2011 Marek "p2004a" Rusinowski
Tarjan algorithm
*/
#include <cstdio>
#include <vector>
#define MAXN 1000000
std:: vector < int > edges[ MAXN] ;
bool visited[ MAXN] ;
std:: vector < int > sorted;
void dfs( int v) {
visited[ v] = true ;
for ( unsigned i = 0 ; i < edges[ v] .size ( ) ; ++ i) {
if ( ! visited[ edges[ v] [ i] ] ) {
dfs( edges[ v] [ i] ) ;
}
}
sorted.push_back ( v) ;
}
int main( ) {
int a, b, n, m;
scanf ( "%d %d" , & n, & m) ;
for ( int i = 0 ; i < m; ++ i) {
scanf ( "%d %d" , & a, & b) ;
edges[ -- a] .push_back ( -- b) ;
}
for ( int i = 0 ; i < n; ++ i) {
if ( ! visited[ i] ) {
dfs( i) ;
}
}
for ( int i = n - 1 ; i >= 0 ; -- i) {
printf ( "%d " , sorted[ i] + 1 ) ;
}
printf ( "\n " ) ;
return 0 ;
}
LyoKICBDb3B5cmlnaHQgMjAxMSBNYXJlayAicDIwMDRhIiBSdXNpbm93c2tpCiAgVGFyamFuIGFsZ29yaXRobQoqLwojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8dmVjdG9yPgoKI2RlZmluZSBNQVhOIDEwMDAwMDAKCnN0ZDo6dmVjdG9yPGludD4gZWRnZXNbTUFYTl07CmJvb2wgdmlzaXRlZFtNQVhOXTsKc3RkOjp2ZWN0b3I8aW50PiBzb3J0ZWQ7Cgp2b2lkIGRmcyhpbnQgdikgewogIHZpc2l0ZWRbdl0gPSB0cnVlOwogIGZvciAodW5zaWduZWQgaSA9IDA7IGkgPCBlZGdlc1t2XS5zaXplKCk7ICsraSkgewogICAgaWYgKCF2aXNpdGVkW2VkZ2VzW3ZdW2ldXSkgewogICAgICBkZnMoZWRnZXNbdl1baV0pOwogICAgfQogIH0KICBzb3J0ZWQucHVzaF9iYWNrKHYpOwp9CgppbnQgbWFpbigpIHsKICBpbnQgYSwgYiwgbiwgbTsKICBzY2FuZigiJWQgJWQiLCAmbiwgJm0pOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgKytpKSB7CiAgICBzY2FuZigiJWQgJWQiLCAmYSwgJmIpOwogICAgZWRnZXNbLS1hXS5wdXNoX2JhY2soLS1iKTsKICB9CiAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgIGlmICghdmlzaXRlZFtpXSkgewogICAgICBkZnMoaSk7CiAgICB9CiAgfQogIGZvciAoaW50IGkgPSBuIC0gMTsgaSA+PSAwOyAtLWkpIHsKICAgIHByaW50ZigiJWQgIiwgc29ydGVkW2ldICsgMSk7CiAgfQogIHByaW50ZigiXG4iKTsKICByZXR1cm4gMDsKfQo=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout