main = getLine >>= putStrLn . unwords . map show . maybe [-1,-1] id . unbalance 1

unbalance i (c1:c2:c3:cs)
  | c1 == c2 = Just [i, i+1]
  | c1 == c3 = Just [i, i+2]
  | otherwise = unbalance (succ i) (c2:c3:cs)
unbalance i (c1:c2:cs)
  | c1 == c2 = Just [i, i+1]
  | otherwise = Nothing
unbalance _ _ = Nothing