pattern = []
8.times { pattern << gets.chomp }

puts 90
0.upto(7) do |i|
  7.downto(0) do |j|
    print pattern[j][i]
    puts "" if j.zero?
  end
end

puts 180
pattern.reverse.each { |p| puts p.reverse }

puts 270
pattern.each { |p| puts p.reverse }