Mother Vertex

hard
Given a Directed Graph, find a Mother Vertex in the Graph (if present). 
A Mother Vertex is a vertex through which we can reach all the other vertices of the Graph.

Input Format

First line contains two space separated integers,N and M. Then M lines follow, each line has 2 space separated integers ai and bi.

Output Format

Print the mother vertex if present else print -1.

Constraints

1<= N <= 10000
1<= M <= (N*(N-1))/2
1<= ai, bi <= N

Example

Input
4 3
1 2
2 3
3 4
Output
1
Previous
Kosaraju Algorithm
Next
Minimum Cost To Connect All Cities

Related Questions