Олимпиадный тренинг

Задача 21709. Reverse ribs


Задача

Темы:
A connected oriented unweighted graph is given. It is required to print the numbers of vertices from which all its back edges originate (numbering starts from 1).
 
Input:
Integer n and m - the number of vertices and edges in the graph.
The next m lines contain 2 numbers a and b showing that there is an edge from vertex a to vertex b.
 
Output:
The first line should contain the number n - the number of back edges, the next line should contain the vertices in ascending order without repetition. If there are no back edges, then print -1.