package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code ---*/

	var n, m = nextInt(), nextInt()
	var g = make([][]int, n)
	for i := 0; i < m; i++ {
		var a, b = nextInt() - 1, nextInt() - 1
		g[a] = append(g[a], b)
	}
	//fmt.Fprint(out, g)

	var temp []int
	for i := 0; i < n; i++ {
		var r []int
		r = append(r, i)
		temp = dfs(i, r, g)
		//fmt.Fprintln(out, temp)
		if len(temp) > 0 {
			break
		}
	}

	if len(temp) == 0 {
		fmt.Fprintln(out, -1)
		return
	}

	var check = 1
	var p = 0
	for {
		check = 0
		for i := len(temp) - 1; i >= 0; i-- {
			if i == p || i == p+1 {
				continue
			}
			for _, x := range g[temp[p]] {
				//fmt.Fprintln(out, temp, g[temp[p]], i, temp[i], x, p)
				if x == temp[i] {
					if i < p {
						temp = temp[i : p+1]
						fmt.Fprintln(out, len(temp))
						for _, z := range temp {
							fmt.Fprintln(out, z+1)
						}
						return
					} else {
						temp = append(temp[:p+1], temp[i:]...)
						//fmt.Fprintln(out, temp)
						check = 1
						p += 1
						break
					}
				}
			}
			if check == 1 {
				break
			}
		}
		if check == 0 {
			p += 1
		}
	}
	fmt.Fprintln(out, len(temp))
	for _, z := range temp {
		fmt.Fprintln(out, z+1)
	}
}

func dfs(p int, r []int, g [][]int) []int {
	for _, x := range g[p] {
		for i, y := range r {
			if x == y {
				r = r[i:]
				//fmt.Fprintln(out, x, g[p], r, "ok")
				return r
			}
		}
		//fmt.Fprintln(out, p, x, r, append(r, x))
		temp := dfs(x, append(r, x), g)
		//fmt.Fprintln(out, temp, "continue")
		if len(temp) > 0 {
			return temp
		}
	}
	//fmt.Fprintln(out, "NG")
	var ret []int
	return ret
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 1152