#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
std::ifstream fin("sortaret.in");
std::ofstream fout("sortaret.out");
int main() {
int n, m, x, y, crt;
std::queue<int> queue;
fin >> n >> m;
std::vector<int> gradIntrare(n+1, 0);
std::vector<bool> visited(n+1, false);
std::vector<std::vector<int>> graph(n+1);
while (fin >> x >> y) {
gradIntrare[y]++;
graph[x].push_back(y);
}
for (int i = 1; i<=n; i++) {
std::cout<<i << ": " << gradIntrare[i] << ", ";
}
for (int i = 1; i<=n; i++) {
if (gradIntrare[i] == 0) {
queue.push(i);
visited[i] = true;
}
}
while (!queue.empty()) {
crt = queue.front();
fout << crt << " ";
queue.pop();
for (auto vecin : graph[crt]) {
gradIntrare[vecin]--;
if (gradIntrare[vecin] == 0 && visited[vecin] == false) {
queue.push(vecin);
}
}
}
// for (auto nod : graph) {
// for (auto muchie : nod) {
// std::cout<< muchie << " ";
// }
// std::cout<< "\n";
//
// }
}