import Control.Monad (mplus)
import Data.List (transpose)
import Data.Maybe (fromMaybe)

main = do
  inputs <- fmap lines getContents
  mapM_ (putStrLn.(:[]).fromMaybe 'd'.winner.toField) inputs

toField :: String -> [String]
toField [] = []
toField str = take 3 str : toField (drop 3 str)

isWin :: Char -> [String] -> Maybe Char
isWin c f = horizon `mplus` vertical `mplus` closs
  where horizon = if (any id.map (all (== c)) $ f) then Just c
                                                   else Nothing
        vertical = if (any id.map (all (== c)) $ transpose f) then Just c
                                                              else Nothing
        closs = if (any id.map (all (== c)) $ getCloss f)  then Just c
                                                           else Nothing

getCloss f = [zipWith (!!) f [0,1,2], zipWith (!!) f [2,1,0]]

winner :: [String] -> Maybe Char
winner f = isWin 'o' f `mplus` isWin 'x' f `mplus` Nothing