table = zip "0123456789" ["* = ****",
                          "* =* ***",
                          "* =** **",
                          "* =*** *",
                          "* =**** ",
                          " *= ****",
                          " *=* ***",
                          " *=** **",
                          " *=*** *",
                          " *=**** "]
main :: IO ()
main = do
  ls <- getContents
  let ls' = map to5 . lines $ ls
      ansL = map solve ls'
  loopPut ansL

loopPut :: [[String]] -> IO ()
loopPut l = do
  if l == []
    then return ()
    else do
      putStrLn "\n"
      mapM_ putStrLn (head l)
      loopPut (tail l)

to5 :: String -> String
to5 xs = (replicate (5- (length xs)) '0') ++ xs

solve :: String -> [String]
solve xs = spin $ deform xs
  where
    spin :: [String] -> [String]
    spin [[],[],[],[],[]] = []
    spin [(a:as),(b:bs),(c:cs),(d:ds),(e:es)] = [a,b,c,d,e]:(spin [as,bs,cs,ds,es])

    deform :: String -> [String]
    deform = map toA
      where
        toA :: Char -> String
        toA x = toA' x table
          where
            toA' :: Char -> [(Char,String)] -> String
            toA' x ((a,b):r)
              | x == a = b
              | otherwise = toA' x r