import Data.Maybe

main = interact $ put . sol

sol = unballance 1

put = (\(s,t) -> show s ++ " " ++ show t) . fromMaybe (-1,-1)

unballance n s@(a:b:s')
  | length s<2  = Nothing
  | a==b        = Just (n,n+1)
  | length s>2 && a==head s'
                = Just (n,n+2)
  | otherwise   = unballance (n+1) (b:s')
