module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e,t){"use strict";function n(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var l,i=r[Symbol.iterator]();!(n=(l=i.next()).done)&&(t.push(l.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=n(r[0].split(" ").map(function(r){return Number(r)}),2),t=e[0],o=e[1],u=new Array(t),l=0;l<t;l++)u[l]=[];for(var i=0;i<o;i++){var f=n(r[i+1].split(" ").map(function(r){return Number(r)-1}),2),a=f[0],c=f[1];u[a].push(c)}for(var p=0;p<t;p++){var s=new Array(t).fill(!1);s[p]=1;for(var v=[{v:p,fl:s,k:1}];v.length>0;){var y=v.pop(),d=!0,b=!1,m=void 0;try{for(var g,h=u[y.v][Symbol.iterator]();!(d=(g=h.next()).done);d=!0){var x=g.value;if(x==p){console.log(y.k);for(var S=0;S<t;S++)1==y.fl[S]&&console.log(S+1);return}if(1!=y.fl[x]){var j=y.fl.concat();j[x]=1,v.push({v:x,fl:j,k:y.k+1})}}}catch(r){b=!0,m=r}finally{try{d||null==h.return||h.return()}finally{if(b)throw m}}}}console.log(-1)}},function(r,e){r.exports=require("fs")}]);