import Control.Monad

main :: IO ()
main = do
  ls <- replicateM 8 getLine
  let ls' = spin90 ls
      ls'' = spin90 ls'
      ls''' = spin90 ls''
  print 90
  mapM_ putStrLn ls'
  print 180
  mapM_ putStrLn ls''
  print 270
  mapM_ putStrLn ls'''

spin90 :: [String] -> [String]
spin90 ("":_) = []
spin90 [(a:as),(b:bs),(c:cs),(d:ds),(e:es),(f:fs),(g:gs),(h:hs)]
  = [h,g,f,e,d,c,b,a]:(spin90 [as,bs,cs,ds,es,fs,gs,hs]) 