const int MAXSIZE = 1e6 + 7;
struct Tail
{
int to, next;
}tail[MAXSIZE];
int head[MAXSIZE] = {0}, tot = 0;
bool visit[MAXSIZE] = {0};
void Add(int _head, int _tail) {
tail[++tot].to = _tail;
tail[tot].next = head[_head];
head[_head] = tot;
}
int main()
{
int n,m,start,over;
while (cin >> n >>m) {
tot = 0;
memset(head, 0, sizeof(head));
memset(tail, 0, sizeof(tail));
memset(visit, 0, sizeof(visit));
for (int i = 0; i < m; ++i) {
cin >> start >> over;
Add(start, over);
}
for (int i = 1; i <= n; i++)
{
if(visit[i]) continue;
visit[i] = true;
cout << i <<" ";
for (int j = head[i]; j; j = tail[j].next)
{
if(visit[tail[j].to]) continue;
visit[tail[j].to] = true;
cout << tail[j].to << " ";
}
}
cout << endl;
}
return 0;
}
#define HEAD(input) cf.head[input]
#define NEXT(input) cf.tail[input].nx
#define VALUE(input) cf.tail[input].v
#define TO(input) cf.tail[input].to
class ChainForward {
struct ChainForwardNode {
ChainForwardNode() :to(0), nx(0), v(0) {}
int to,nx;
long long v;
};
public:
ChainForward(int headLen, int edgeLen) {
init(headLen, edgeLen);
}
void init(int headLen, int edgeLen) {
head.assign(headLen, 0);
tail.assign(edgeLen, {});
tot = 1;
}
int add(int from,int to,int val) {
tail[++tot].to = to;
tail[tot].v = val;
tail[tot].nx = head[from];
head[from] = tot;
return tot;
}
int tot;
vector<int> head;
vector<ChainForwardNode> tail;
};
ChainForward cf(1000,10000);
void slove(){
for (int i = HEAD(from); i; i = NEXT(i)) {
if (VALUE(i) <= 0)continue;
int to = TO(i);
}
}