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;
bool findCycle(vector<vector<int>>& graph, vector<int>& seen,
               vector<int>& parent, int cur, pair<int, int>& cycleStartEnd) {
  seen[cur] = 1;
  for (int next : graph[cur]) {
    if (seen[next] == 0) {
      parent[next] = cur;
      if (findCycle(graph, seen, parent, next, cycleStartEnd)) return true;
    } else if (seen[next] == 1) {
      cycleStartEnd.first = next;
      cycleStartEnd.second = cur;
      return true;
    }
  }
  seen[cur] = 2;
  return false;
}
bool hasCycle(vector<vector<int>>& graph, vector<int>& seen, int cur) {
  seen[cur] = 1;
  for (int next : graph[cur]) {
    if ((seen[next] == 1) || (seen[next] == 0 && hasCycle(graph, seen, next)))
      return true;
  }
  seen[cur] = 2;
  return false;
}
int dfs(vector<vector<int>>& graph, vector<int>& seen, vector<int>& cycleIndex,
        int cur, vector<int>& ends, vector<int>& incrCycleIndex,
        int cycleSize) {
  int maxEnd = -1;
  if (cycleIndex[cur] < 0) seen[cur] = 1;
  for (int next : graph[cur]) {
    if (seen[next] == 0) {
      if (cycleIndex[next] >= 0)
        maxEnd = max(maxEnd, cycleIndex[next]);
      else
        maxEnd = max(maxEnd, dfs(graph, seen, cycleIndex, next, ends,
                                 incrCycleIndex, cycleSize));
    } else {
      maxEnd = max(maxEnd, ends[next]);
      if (ends[next] >= 0) {
        maxEnd =
            max(maxEnd, ends[next] >= cycleSize ? ends[next]
                                                : incrCycleIndex[ends[next]]);
      }
    }
  }
  ends[cur] = maxEnd;
  return maxEnd;
}
bool ok(int vert, vector<vector<int>>& graph, int n) {
  vector<int> seen(n + 1, 0);
  seen[vert] = 2;
  bool cycleExists = false;
  for (int cur = 1; !cycleExists && cur <= n; ++cur) {
    if (cur != vert) cycleExists |= hasCycle(graph, seen, cur);
  }
  return !cycleExists;
}
vector<int> removeInvalidNodes(vector<int>& nodes,
                               vector<pair<int, int>>& jumps) {
  int start = -1;
  int end = -1;
  vector<pair<int, int>> merged;
  for (const auto& se : jumps) {
    int s = se.first;
    int e = se.second;
    if (start < 0 && end < 0) {
      start = s;
      end = e;
    } else if (s < end)
      end = max(end, e);
    else {
      merged.push_back({start, end});
      start = s;
      end = e;
    }
  }
  if (start >= 0 && end >= 0) merged.push_back({start, end});
  for (const auto& se : merged) {
    for (int vert = se.first; vert <= se.second; ++vert) {
      nodes[vert % nodes.size()] = 0;
    }
  }
  vector<int> cycle;
  for (int node : nodes) {
    if (node > 0) cycle.push_back(node);
  }
  return cycle;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n + 1, vector<int>());
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
  }
  vector<int> seen(n + 1, 0);
  vector<int> parent(n + 1, 0);
  pair<int, int> cycleStartEnd;
  int res = -1;
  bool cycleExists = false;
  for (int i = 1; i <= n && !cycleExists; ++i) {
    seen.clear();
    parent.clear();
    cycleExists = findCycle(graph, seen, parent, i, cycleStartEnd);
  }
  if (cycleExists) {
    vector<int> mainCycle;
    for (int v = cycleStartEnd.second; v != cycleStartEnd.first;
         v = parent[v]) {
      mainCycle.push_back(v);
    }
    fill_n(seen.begin(), n + 1, 0);
    mainCycle.push_back(cycleStartEnd.first);
    reverse(mainCycle.begin(), mainCycle.end());
    vector<int> cycleIndex(n + 1, -1);
    vector<int> incrCycleIndex(n + 1, -1);
    for (int i = 0; i < mainCycle.size(); ++i) {
      cycleIndex[mainCycle[i]] = i;
      incrCycleIndex[i] = i;
    }
    vector<int> ends(n + 1, -1);
    for (int i = 1; i <= n; ++i) ends[i] = i - 1;
    vector<pair<int, int>> jumps;
    for (int i = 0; i < mainCycle.size(); ++i) {
      int vert = mainCycle[i];
      cycleIndex[mainCycle[i]] += mainCycle.size();
      incrCycleIndex[i] += mainCycle.size();
      int end = dfs(graph, seen, cycleIndex, vert, ends, incrCycleIndex,
                    mainCycle.size());
      if (end > i + 1) {
        jumps.push_back({i + 1, end - 1});
      }
    }
    mainCycle = removeInvalidNodes(mainCycle, jumps);
    for (int vert : mainCycle) {
      if (ok(vert, graph, n)) {
        res = vert;
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}