import Control.Monad
import Data.List
import Data.Array
import Data.Array.ST

main :: IO ()
main = do
  [n,m] <- map (read :: String -> Int) . words <$> getLine
  uvm <- toArray n . map ((\[x,y] -> (x,y)) . map (read :: String -> Int) . words) <$> getNLine_ m
  [s,t] <- map (read :: String -> Int) . words <$> getLine
  let ary = foldl1 (mProduct n) [uvm,uvm,uvm]
  print $ ans n (s,t) ary 1 ary

ans :: Int -> (Int,Int) -> Array (Int,Int) Int -> Int -> Array (Int,Int) Int -> Int
ans n i ary k pary
  | k == n+1 = -1
  | pary ! i /= 0 = k
  | otherwise = ans n i ary (k+1) $ mProduct n pary ary

toArray :: Int -> [(Int,Int)] -> Array (Int,Int) Int
toArray n is = runSTArray $ do
  ary <- newArray ((1,1),(n,n)) 0
  sequence_ [do
    writeArray ary i 1
    | i <- is]
  return ary

mProduct :: Int -> Array (Int,Int) Int -> Array (Int,Int) Int -> Array (Int,Int) Int
mProduct n a b = runSTArray $ do
  ary <- newArray ((1,1),(n,n)) 0
  sequence_ [do
    writeArray ary (s,t) $ func (s,t)
    | s <- [1..n], t <- [1..n]]
  return ary
  where func (s,t) = foldl (\acc k -> (+) acc $ a ! (s,k) * b ! (k,t)) 0 [1..n]

getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine
