-- Try AtCoder
-- author: Leonardone @ NEETSDKASU
 
import qualified Data.Map as Map
import Data.List (find)

main = putStrLn . solve =<< getLine



solve xs = ans where
    ys = [ (take j . drop i $ xs, i, j) | i <- [0 .. length xs], j <- [2 .. length xs]]
    f m []     = if m == Map.empty then 0 else maximum $ Map.elems m
    f m (z:zs) = let n = Map.insertWith (+) z 1 m in f n zs
    g (zs, _, j) = let k = f Map.empty zs in j < k * 2
    ans = case find g ys of
        Just (_, i, j) -> show i ++ " " ++ show (i + j -1)
        Nothing -> "-1 -1"
    