### BUGGY CODE ###

import sys
import heapq

INF = float("inf")


def Topological_sorting(E):
    N = len(E)
    # 入次数0の節点を列挙
    in_deg = [0]*N
    for i in range(N):
        for to in E[i]:
            in_deg[to] += 1

    head = 0
    ans = [v for v in range(N) if in_deg[v] == 0]

    # 入次数0のものを順番に走査。同時に入次数を更新
    while head < len(ans):                  # O(V+E)
        v = ans[head]
        for t in E[v]:
            in_deg[t] -= 1
            if in_deg[t] == 0:
                ans.append(t)
        head += 1
    if len(ans) != N:
        return False
    return ans


def main():
    N, M = map(int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        E[a-1].append(b-1)

    # print(rE)
    loop = Topological_sorting(E)
    if loop is not False:
        print(-1)
        return

    need = [1]*N
    while True:
        # 閉路を一つ探す。
        # グラフの単純化から始める
        # 入次数0の子はいらない子。
        # 出次数0の子はいらない子。

        in_deg = [0]*N
        out_deg = [0]*N
        for i in range(N):
            out_deg[i] = len(E[i])
            for to in E[i]:
                in_deg[to] += 1
        for i in range(N):
            if in_deg[i] == 0 or out_deg[i] == 0:
                need[i] = 0
        for i in range(N):
            if need[i] == 0:
                E[i] = []
            else:
                E[i] = [u for u in E[i] if need[u] == 1]

        # 答えがすでに得られているなら、
        # breakする。
        in_deg = [0]*N
        for i in range(N):
            for to in E[i]:
                in_deg[to] += 1
        cand = [i for i in range(N) if in_deg[i] > 1]
        # print("cand", cand, need)
        # print(E)
        if len(cand) == 0:
            break

        # 用いられない辺が存在するとのこと。
        # その終点からスタートする
        # 簡単に、入次数が1以上の点だ
        start = cand[0]
        q = [start]
        hist = set()
        while q:
            v = q[-1]
            hist.add(v)
            q.extend(E[v])
            if v == q[-1]:
                q.pop()
                hist.remove(v)
            loop = False
            for u in E[v]:
                if u in hist:
                    loop = True
                    break
            if loop:
                break
        # print("hist", hist)
        for i in range(N):
            if i not in hist:
                need[i] = 0
        # print(need)

    ans = [i for i, n in enumerate(need, start=1) if n == 1]
    print(len(ans))
    print(*ans, sep="\n")
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
# https://atcoder.jp/contests/abc142/submissions/7764934
# ほぼまんま。


def main():
    N, M = map(int, input().split())
    E = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        E[a-1].add(b-1)

    # スタート地点は全て試す
    for start in range(N):
        visited = [0]*N
        Q = deque([(start, {start})])
        append, popleft = Q.append, Q.popleft
        visited[start] = 1

        while Q:
            v, route = popleft()
            # これまで通ってきた頂点と行き先の積集合
            s = route & E[v]
            # sが空集合(ループでない)か、行き先に始点のみが含まれる場合は継続
            # 行き先に始点以外の場所が含まれるなら、もっと良い始点の選び方がある。
            # if not (not s or (s == {start})):
            if s and s != {start}:
                continue
            for dest in E[v]:
                if dest == start:
                    print(len(route))
                    print(*[n+1 for n in route], sep="\n")
                    return
                if visited[dest]:
                    continue
                visited[dest] = 1
                append((dest, route | {dest}))
    print(-1)
    return


if __name__ == '__main__':
    main()