### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    g = defaultdict(set)
    rg = defaultdict(set)
    for a, b in AB:
        g[a].add(b)
        rg[b].add(a)
    
    def ok(v):
        v = set(v)
        for u in v:
            if not(len(v & g[u]) == 1 and len(v & rg[u]) == 1):
                return False
        return True

    def dfs(u):
        su = set(u)
        for v in g[u[-1]]:
            if v == u[0]:
                if ok(u):
                    return u
                else:
                    return []
            elif v in su:
                return []
            u.append(v)
            ret = dfs(u)
            if ret:
                return ret
            u.pop()
        
        return []

    for i in range(1, N+1):
        v = dfs([i])
        if v:
            print(len(v))
            for u in v:
                print(u)
            return

    print(-1)


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    (slv(N, M, AB))

    # N = 1000
    # M = 2000
    # AB = set()
    # while len(AB) != M:
    #     AB.add((random.randint(1, N+1), random.randint(1, N+1)))
    # print('start')
    # (slv(N, M, AB))



if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv(N, M, AB):
    from collections import defaultdict

    g = defaultdict(list)
    for a, b in AB:
        g[a].append(b)

    def bfs(s):
        q = deque([s])
        done = {}
        done[s] = 0
        prev = {}
        goal = None
        while q:
            u = q.popleft()
            for v in g[u]:
                if v not in done:
                    done[v] = done[u] + 1
                    prev[v] = u
                    q.append(v)
                if v == s:
                    goal = u
                    break
        if goal is  None:
            return None
        v = goal
        ans = [s]
        while v in prev:
            ans.append(v)
            v = prev[v]
        return ans

    from collections import deque
    ans = [0] * (2*N)
    for i in range(1, N+1):
        a = bfs(i)
        if a and len(ans) > len(a):
            ans = a
    if len(ans) == (2*N):
        print(-1)
        return
    print(len(ans))
    print(*ans, sep='\n')


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    slv(N, M, AB)


if __name__ == '__main__':
    main()