
-- https://atcoder.jp/contests/abc135/tasks/abc135_f

junkanstr :: Int -> String -> String
junkanstr i s =
    s1 ++ s2
    where 
        l = length s
        i2 = mod i l
        s1 = drop i2 s
        s2 = take i2 s

junkancomp :: String -> String -> Bool
junkancomp s1 s2 =
    if l1 == l2
    then
        any (\i -> s1 == (junkanstr i s2)) [0..(l1-1)]
    else
        False
    where 
        l1 = length s1
        l2 = length s2

func3 :: String -> String
func3 s =

    func2 1

    where 
        sl = length s

        func2 l =
            if q2 == 0 
            then 
                if s2 == s
                then
                    s3
                else
                    func2 (1 + l)
            else 
                func2 (1 + l)
            where 
                (q1,q2) = quotRem sl l
                s3 = take l s 
                s2 = concat $ replicate q1 s3

bubun :: String -> String  -> Bool
bubun s1 s2 =
    if ld < 0
    then
        False
    else
        any (\i -> s1 == (take l1 $ drop i s2)) [0..ld]
    where
        l1 = length s1
        l2 = length s2
        ld = l2 - l1

bubun2 :: String -> String  -> Int
bubun2 s1 s2 =
    inner $ div (length s2) (length s1)
    where
        inner 0 = 0
        inner n = 
            if result
            then
                n
            else
                inner (n-1)
            where 
                s = concat $ replicate n s1
                result = bubun s s2

myround :: [a] -> [[a]]
myround [] = [[]]
myround arr =
    map (\i -> (take (l-i) $ drop i arr) ++ take i arr) [0..(l-1)]
    where 
        l = length arr

main :: IO ()
main = do
    str_s <- getLine    
    str_t <- getLine    

    let len_s = length str_s
    let len_t = length str_t

    let l_s = func3 str_s
    let l_t = func3 str_t

    let count = div len_t len_s

    if junkancomp l_s l_t 
    then 
        print (-1)
    else
        print $ bubun2 str_t (concat $ replicate (2+count) str_s ) 

