#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define maxn 5005
int scc[maxn], low[maxn], num[maxn], st[maxn], is[maxn];
int nsc, mn, sz, n, m;
vector<int> g[maxn];
void dfs(int p) {
low[p] = num[p] = mn++;
st[sz++] = p;
for(int i = 0; i < g[p].size(); i++) {
int k = g[p][i];
if(scc[k] == -1) {
if(num[k] == -1) dfs(k);
low[p] = min(low[p], low[k]);
}
}
if(low[p] == num[p]) {
while(scc[p] != nsc)
scc[st[--sz]] = nsc;
nsc++;
}
}
void getscc() {
nsc = mn = sz = 0;
for(int i = 0; i < n; i++) {
if(num[i] == -1) dfs(i);
}
}
int main() {
while(scanf("%d", &n), n) {
memset(num, -1, sizeof(num));
memset(scc, -1, sizeof(scc));
memset(is, 0, sizeof(is));
for(int i = 0; i < n; i++) g[i].clear();
scanf("%d", &m);
while(m--) {
int a, b;
scanf("%d%d", &a, &b);
g[--a].push_back(--b);
} getscc();
for(int i = 0; i < n; i++) {
if(scc[i] != -1, !is[scc[i]]) {
for(int j = 0; j < g[i].size(); j++) {
if(scc[g[i][j]] != scc[i]) {
is[scc[i]] = 1; break;
}
}
}
}
bool flag = 0;
for(int i = 0; i < n; i++) {
if(scc[i] != -1, !is[scc[i]]) {
printf("%s%d", flag?" ":"", i+1); flag = 1;
}
} printf("\n");
}
}