module Main where import Control.Monad import Control.Applicative import Data.Maybe import Data.List import qualified Text.Printf import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString as BC ------------------------------------------ isKadomatsu :: Int -> Int -> Int -> Bool isKadomatsu a b c = (a < b && b > c) || (a > b && b < c) main :: IO () main = do q <- words <$> getLine let [a1, b1, c1] = map (\x -> if x == "?" then 1 else read x) q [a2, b2, c2] = map (\x -> if x == "?" then 4 else read x) q r1 = if isKadomatsu a1 b1 c1 then "1" else "" r2 = if isKadomatsu a2 b2 c2 then "4" else "" putStrLn $ r1 ++ r2 ------------------------------------------ {- Int input -} parseInt :: BC.ByteString -> Int parseInt = fst . fromJust . BC.readInt parseInts :: BC.ByteString -> [Int] parseInts = map parseInt <$> BC.words readInt :: IO Int readInt = parseInt <$> BC.getLine readInts :: IO [Int] readInts = parseInts <$> BC.getLine {- Double Formatting -} doubleFmt :: Double -> String doubleFmt = Text.Printf.printf "%.12f"