using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    private int N;
    private int M;
    private List<Edge> Edges;
    private Stack<int> S;
    private bool[] F;
    private List<int>[] E;
    private bool[] Searched;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        Edges = new List<Edge>();
        for (int i = 0; i < M; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            Edges.Add(new Edge(a, b));
        }

        S = new Stack<int>();
        F = new bool[N];
        E = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            E[i] = new List<int>();
        }

        foreach (var edge in Edges)
        {
            E[edge.A].Add(edge.B);
        }
        
        Searched = new bool[N];

        bool f = false;

        for (int i = 0; i < N; i++)
        {
            if (!Searched[i])
            {
                if (Search(i))
                {
                    f = true;
                    break;
                }
            }
        }

        if (!f)
        {
            Console.WriteLine(-1);
            return;
        }
        
        //Console.WriteLine(string.Join(" ",S));

        int begin = S.Pop();

        HashSet<int> nodeHs = new HashSet<int>();
        List<int> nodeL = new List<int>();
        while (S.Count > 0)
        {
            int pop = S.Pop();
            nodeL.Add(pop);
            nodeHs.Add(pop);
            if(pop == begin)
                break;
        }

        nodeL.Reverse();

        while (true)
        {
            var hs = new HashSet<Edge>();
            var next = new List<Edge>();
            foreach (var edge in Edges)
            {
                if (nodeHs.Contains(edge.A) && nodeHs.Contains(edge.B))
                {
                    hs.Add(edge);
                    next.Add(edge);
                }
            }

            if (next.Count == nodeL.Count)
            {
                break;
            }

            for (int i = 0; i < nodeL.Count; i++)
            {
                int nextInd = (i + 1) % nodeL.Count;
                var e = new Edge(nodeL[i], nodeL[nextInd]);
                if (hs.Contains(e))
                {
                    hs.Remove(e);
                }
            }

            var unused = hs.ToArray()[0];
            var nextNodeHs = new HashSet<int>();
            var nextNodeL = new List<int>();

            int startInd = nodeL.IndexOf(unused.B);

            for (int i = 0; i < nodeL.Count; i++)
            {
                int index = (i + startInd) % nodeL.Count;
                nextNodeHs.Add(nodeL[index]);
                nextNodeL.Add(nodeL[index]);
                if(nodeL[index] == unused.A)
                    break;
            }

            nodeHs = nextNodeHs;
            nodeL = nextNodeL;
        }
        Console.WriteLine(nodeL.Count);
        Console.WriteLine(string.Join("\n",nodeL.Select(i=>i+1)));
    }

    private bool Search(int i)
    {
        S.Push(i);
        if (F[i])
            return true;
        F[i] = true;
        foreach (var i1 in E[i])
        {
            if (Search(i1))
                return true;
        }

        S.Pop();
        F[i] = false;
        Searched[i] = true;
        return false;
    }
    
    

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

struct Edge
{
    public int A, B;

    public Edge(int a, int b)
    {
        A = a;
        B = b;
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13792