import Data.Maybe

main = interact $ put . sol

sol = unballance 1

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

unballance _ [_]  = Nothing
unballance n [a,b]
  | a==b      = Just (n, n+1)
  | otherwise = Nothing
unballance n (a:b:c:s)
  | a==b || b==c || a==c = Just (n,n+2)
  | otherwise = unballance (n+1) (b:c:s)
