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;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
vector<int> g[500010];
char done[500010];
int topoSort[500010];
int wsk;
void dfsSCC(int nr) {
  done[nr] = 1;
  for (int i = 0; i < ((int)g[nr].size()); ++i)
    if (!done[g[nr][i]]) dfsSCC(g[nr][i]);
  topoSort[wsk++] = nr;
}
int sCC, ktoraSCC[500010], ileSCC[500010];
void findSCC(int nr) {
  ktoraSCC[nr] = sCC;
  for (int i = 0; i < ((int)g[nr].size()); ++i)
    if (!ktoraSCC[g[nr][i]]) findSCC(g[nr][i]);
}
bool found;
vector<int> S;
list<int> cykl;
list<int>::iterator head, posCykl[500010];
bool wCyklu[500010];
vector<int> res;
void findFirst(int nr) {
  if (found) return;
  done[nr] = 1;
  S.push_back(nr);
  for (int i = 0; i < ((int)g[nr].size()); ++i)
    if (!done[g[nr][i]])
      findFirst(g[nr][i]);
    else if (done[g[nr][i]] == 1 && !found) {
      found = 1;
      for (int j = ((int)S.size()) - 1; j >= (0); --j) {
        cykl.push_front(S[j]);
        if (S[j] == g[nr][i]) break;
      }
      head = cykl.begin();
      for (list<int>::iterator it = cykl.begin(); it != cykl.end(); it++) {
        posCykl[*it] = it;
        wCyklu[*it] = 1;
      }
    }
  S.pop_back();
  done[nr] = 2;
}
void remove(list<int>::iterator it) {
  if (it == head) head++;
  cykl.erase(it);
}
list<int>::iterator next(list<int>::iterator it) {
  it++;
  if (it == cykl.end()) it = head;
  return it;
}
void wycieciwuj(int nr) {
  for (int i = 0; i < ((int)g[nr].size()); ++i)
    if (wCyklu[g[nr][i]]) {
      list<int>::iterator pom = posCykl[nr];
      list<int>::iterator nast = next(pom);
      while (!cykl.empty()) {
        if (*nast == g[nr][i]) break;
        pom = next(nast);
        wCyklu[*nast] = 0;
        remove(nast);
        nast = pom;
      }
    }
}
int gdzieNaCykl[500010];
bool removed[500010];
int nextNaCyklu[500010];
int initialPos[500010];
int originalNext[500010];
int lengthC;
void szamajCykl(int p, int k) {
  if (cykl.empty()) return;
  vector<int> V;
  int firstToRemove;
  if (!removed[p])
    firstToRemove = *next(posCykl[p]);
  else
    firstToRemove = p;
  while (removed[firstToRemove]) {
    V.push_back(firstToRemove);
    firstToRemove = nextNaCyklu[firstToRemove];
  }
  while (!V.empty()) {
    nextNaCyklu[V.back()] = firstToRemove;
    V.pop_back();
  }
  int firstToSave = k;
  while (removed[firstToSave]) {
    V.push_back(firstToSave);
    firstToSave = nextNaCyklu[firstToSave];
  }
  while (!V.empty()) {
    nextNaCyklu[V.back()] = firstToSave;
    V.pop_back();
  }
  if (firstToRemove == firstToSave) {
    int start1 = initialPos[originalNext[p]],
        start2 = initialPos[firstToRemove];
    if (start2 < start1) start2 += lengthC;
    int end1 = initialPos[k], end2 = initialPos[firstToSave];
    if (end2 < end1) end2 += lengthC;
    if (end2 - end1 > start2 - start1) cykl.clear();
    return;
  }
  list<int>::iterator it = posCykl[firstToRemove];
  list<int>::iterator pom;
  while (!cykl.empty()) {
    if (*it == firstToSave) break;
    pom = next(it);
    nextNaCyklu[*it] = *pom;
    removed[*it] = 1;
    remove(it);
    it = pom;
  }
}
void dfs(int nr) {
  done[nr] = 1;
  S.push_back(nr);
  for (int i = 0; i < ((int)g[nr].size()); ++i) {
    if (wCyklu[g[nr][i]])
      szamajCykl(S.front(), g[nr][i]);
    else if (!done[g[nr][i]])
      dfs(g[nr][i]);
    else if (done[g[nr][i]] == 1) {
      cykl.clear();
    } else if (gdzieNaCykl[g[nr][i]] != -1)
      szamajCykl(S.front(), gdzieNaCykl[g[nr][i]]);
    if (gdzieNaCykl[nr] == -1) gdzieNaCykl[nr] = gdzieNaCykl[g[nr][i]];
  }
  S.pop_back();
  done[nr] = 2;
}
bool go(int n) {
  for (int i = 0; i < (n); ++i)
    if (!done[i]) dfsSCC(i);
  for (int i = 0; i < (n); ++i)
    if (!ktoraSCC[topoSort[i]]) {
      sCC++;
      findSCC(topoSort[i]);
    }
  for (int i = 0; i < (n); ++i) ileSCC[ktoraSCC[i]]++;
  int pom = 0;
  for (int i = (1); i <= (sCC); ++i)
    if (ileSCC[i] > 1) pom++;
  if (!pom) return 0;
  if (pom > 1) return 0;
  if (pom == 1) {
    int superCykl;
    for (int i = (1); i <= (sCC); ++i)
      if (ileSCC[i] > 1) {
        superCykl = i;
        break;
      }
    for (int i = 0; i < (n); ++i) done[i] = 0;
    for (int i = 0; i < (n); ++i)
      if (ktoraSCC[i] == superCykl) {
        findFirst(i);
        break;
      }
    for (int i = 0; i < (n); ++i)
      if (wCyklu[i]) wycieciwuj(i);
    lengthC = cykl.size();
    int pom1 = 0;
    for (list<int>::iterator it = cykl.begin(); it != cykl.end(); it++) {
      initialPos[*it] = pom1++;
      originalNext[*it] = *next(it);
    }
    for (int i = 0; i < (n); ++i) {
      done[i] = 0;
      gdzieNaCykl[i] = -1;
    }
    for (list<int>::iterator it = cykl.begin(); it != cykl.end(); it++)
      gdzieNaCykl[*it] = *it;
    list<int> cykl1 = cykl;
    for (list<int>::iterator it = cykl1.begin(); it != cykl1.end(); it++)
      dfs(*it);
  }
  return 1;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    g[a].push_back(b);
  }
  if (!go(n) || cykl.empty()) {
    printf("-1\n");
  } else {
    printf("%d\n", cykl.front() + 1);
  }
  return 0;
}