#include <iostream>
#include <vector>
#include <algorithm>
#define WHITE 0
#define GREY 1
#define BLACK 2
using namespace std;
bool dfs (int v, vector<int>* vertex, int* state, vector<int> &result, int size)
{
state[v] = GREY;
for (int i = 0; i < vertex[v].size(); i++)
{
int dest = vertex[v].at(i);
if (state[dest] == WHITE)
{
if (dfs(dest, vertex, state, result, size))
return true;
}
else if (state[dest] == GREY)
{
return true;
}
}
state[v] = BLACK;
result.push_back(v+1);
return false;
}
void topologicalSort(vector<int>* vertex, int* state, vector<int> &result, int size)
{
for (int i = 0; i < size; i++)
{
if (state[i] == WHITE)
{
bool cyclic = dfs(i, vertex, state, result, size);
if (cyclic)
{
result.clear();
result.push_back(-1);
return;
}
}
}
reverse(result.begin(), result.end());
}
int main()
{
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> vertex[n];
int state[n];
vector<int> result;
fill (state, state + n, WHITE);
for (int i = 0; i < n; i++)
{
int begin, end;
cin >> begin >> end;
vertex[begin-1].push_back(end-1);
}
topologicalSort(vertex, state, result, n);
for (int i = 0; i < result.size(); i++)
cout << result.at(i) << " ";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojZGVmaW5lIFdISVRFIDAKI2RlZmluZSBHUkVZIDEKI2RlZmluZSBCTEFDSyAyCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpib29sIGRmcyAoaW50IHYsIHZlY3RvcjxpbnQ+KiB2ZXJ0ZXgsIGludCogc3RhdGUsIHZlY3RvcjxpbnQ+ICZyZXN1bHQsIGludCBzaXplKQp7CglzdGF0ZVt2XSA9IEdSRVk7Cglmb3IgKGludCBpID0gMDsgaSA8IHZlcnRleFt2XS5zaXplKCk7IGkrKykKCXsKCQlpbnQgZGVzdCA9IHZlcnRleFt2XS5hdChpKTsKCQlpZiAoc3RhdGVbZGVzdF0gPT0gV0hJVEUpCgkJewoJCQlpZiAoZGZzKG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