Problem: Petr is a detective in Braginsk. Somebody stole a huge amount of money from a bank and Petr is to catch him. Somebody told Petr that some luxurious car moves along the roads without stopping.

Petr knows that it is the robbers who drive the car. The roads in Braginsk are one-directional and each of them connects two intersections. Petr wants to select one intersection such that if the robbers continue to drive the roads indefinitely, they will sooner or later come to that intersection. The initial position of the robbers is unknown. Find such an intersection that fits the requirements.

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 10^5, 2 ≤ m ≤ 5 ⋅ 10^5) — the number of intersections and the number of directed roads in Braginsk, respectively.

Each of the next m lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — the start and finish of the i-th directed road. It is guaranteed that the robbers can move along the roads indefinitely.

Output

Print a single integer k — the intersection Petr needs to choose. If there are multiple answers, print any. If there are no such intersections, print -1.

Examples

Input

5 6
1 2
2 3
3 1
3 4
4 5
5 3


Output

3

Input

3 3
1 2
2 3
3 1


Output

1

Note

In the first example the robbers can move, for example, along the following routes: (1-2-3-1), (3-4-5-3), (1-2-3-4-5-3-1). We can show that if Petr chooses the 3-rd intersection, he will eventually meet the robbers independently of their route.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adjlist[100005];
vector<int> maincycle;
vector<pair<int, int> > arcs;
map<int, int> positionscycle;
int visitedcycle[100005];
bool visitedcyclecycle[100005];
int visitednoncycle[100005];
int depth[100005];
int furthest[100005];
bool cyclefound;
int cycleorigin = -1;
int bgin, bgincycle;
int cyclesize;
int ans = -1;
bool fatal = false;
bool wtf = false;
void dfscycle(int node) {
  visitedcycle[node] = 1;
  for (vector<int>::iterator iter = adjlist[node].begin();
       iter != adjlist[node].end(); iter++) {
    if (visitedcycle[*iter] == 0) {
      dfscycle(*iter);
    } else if (visitedcycle[*iter] == 1) {
      cyclefound = true;
      cycleorigin = *iter;
    }
    if (cyclefound) {
      if (cycleorigin != -1) {
        if (node == cycleorigin) {
          cycleorigin = -1;
        }
        maincycle.push_back(node);
        visitedcycle[node] = 4;
      }
      return;
    }
  }
  visitedcycle[node] = 3;
}
int dfscyclecycle(int node) {
  if (visitedcyclecycle[node]) {
    return furthest[node];
  }
  visitedcyclecycle[node] = true;
  int x;
  for (vector<int>::iterator iter = adjlist[node].begin();
       iter != adjlist[node].end(); iter++) {
    if (depth[*iter] == 0) {
      x = dfscyclecycle(*iter);
    } else {
      x = *iter;
    }
    if (furthest[node] == -1 || depth[x] > depth[furthest[node]]) {
      furthest[node] = x;
    }
  }
  return furthest[node];
}
bool contains(pair<int, int> segment, int point) {
  if (segment.first < segment.second) {
    if (point >= segment.first && point <= segment.second) {
      return true;
    } else {
      return false;
    }
  } else if (segment.first > segment.second) {
    if (point >= segment.first || point <= segment.second) {
      return true;
    } else {
      return false;
    }
  } else {
    if (segment.first == point) {
      return true;
    } else {
      return false;
    }
  }
}
bool detfirst(int point1, int point2, int point3) {
  if (point2 <= point1 && point3 <= point1) {
    if (point2 == point1) {
      return true;
    } else if (point2 > point3) {
      return false;
    } else if (point2 < point3) {
      return true;
    } else {
      return true;
    }
  } else if (point2 >= point1 && point3 >= point1) {
    if (point2 > point3) {
      return false;
    } else if (point2 < point3) {
      return true;
    } else {
      return true;
    }
  } else if (point2 >= point1 && point3 <= point1) {
    return true;
  } else if (point2 <= point1 && point3 >= point1) {
    if (point2 == point3) {
      return true;
    } else {
      return false;
    }
  }
}
void findintersection() {
  int minarc = -1;
  int maxarc = -1;
  bool possible = true;
  list<pair<int, int> > segments;
  if (!arcs.empty()) {
    segments.push_back({arcs[0].first, arcs[0].second});
  } else {
    if (!maincycle.empty()) {
      ans = maincycle[0];
      visitedcycle[ans] = 5;
    }
  }
  for (vector<pair<int, int> >::iterator iter = arcs.begin();
       iter != arcs.end(); iter++) {
    for (list<pair<int, int> >::iterator iter2 = segments.begin();
         iter2 != segments.end(); iter2++) {
      if (contains((*iter2), (*iter).first) &&
          contains((*iter2), (*iter).second)) {
        if (detfirst((*iter).first, (*iter).second, (*iter2).second)) {
          if ((*iter).first != (*iter2).first ||
              (*iter).second != (*iter2).second) {
            segments.push_back({(*iter).first, (*iter).second});
            iter2 = segments.erase(iter2);
          } else {
          }
        } else {
          segments.push_back({(*iter2).first, (*iter).second});
          segments.push_back({(*iter).first, (*iter2).second});
          iter2 = segments.erase(iter2);
        }
      } else if (contains((*iter2), (*iter).first)) {
        if ((*iter).first != (*iter2).first) {
          segments.push_back({(*iter).first, (*iter2).second});
          iter2 = segments.erase(iter2);
        }
      } else if (contains((*iter2), (*iter).second)) {
        if ((*iter).second != (*iter2).second) {
          segments.push_back({(*iter2).first, (*iter).second});
          iter2 = segments.erase(iter2);
        }
      } else {
        if (contains((*iter), (*iter2).first) &&
            contains((*iter), (*iter2).second)) {
        } else {
          iter2 = segments.erase(iter2);
        }
      }
    }
  }
  int minarc2;
  if (!segments.empty()) {
    minarc2 = (*segments.begin()).first;
  } else {
    possible = false;
  }
  if (possible) {
    ans = minarc2;
    ans = maincycle[ans];
    visitedcycle[ans] = 5;
  }
}
void dfsnocycle(int node) {
  visitednoncycle[node] = 1;
  for (vector<int>::iterator iter = adjlist[node].begin();
       iter != adjlist[node].end(); iter++) {
    if (visitednoncycle[*iter] == 0 && visitedcycle[*iter] != 5) {
      dfsnocycle(*iter);
    } else if (visitednoncycle[*iter] == 1) {
      fatal = true;
    }
  }
  visitednoncycle[node] = 2;
}
int main() {
  int m;
  scanf("%i %i", &n, &m);
  int end1, end2;
  for (int i = 0; i < m; i++) {
    scanf("%i %i", &end1, &end2);
    adjlist[end1].push_back(end2);
  }
  for (int i = 1; i <= n; i++) {
    if (visitedcycle[i] == 0 && !cyclefound) {
      dfscycle(i);
    }
    furthest[i] = -1;
  }
  reverse(maincycle.begin(), maincycle.end());
  int z = 0;
  for (vector<int>::iterator iter = maincycle.begin(); iter != maincycle.end();
       iter++) {
    positionscycle.insert({*iter, z});
    depth[*iter] = z;
    z++;
  }
  cyclesize = maincycle.size();
  for (vector<int>::iterator iter = maincycle.begin(); iter != maincycle.end();
       iter++) {
    bgin = *iter;
    bgincycle = positionscycle[*iter];
    depth[*iter] += cyclesize;
    dfscyclecycle(*iter);
  }
  z = 0;
  for (vector<int>::iterator iter = maincycle.begin(); iter != maincycle.end();
       iter++) {
    if (furthest[*iter] != maincycle[(z + 1) % cyclesize]) {
      arcs.push_back({positionscycle[furthest[*iter]], z});
    }
    z++;
  }
  findintersection();
  for (int i = 1; i <= n; i++) {
    if (visitednoncycle[i] == 0 && visitedcycle[i] != 5) {
      dfsnocycle(i);
    }
  }
  if (fatal) {
    printf("-1");
    return 0;
  }
  printf("%i", ans);
  return 0;
}