def rotate90 array
  length = array.size
  rotated = Array.new(length).map{Array.new(length)}
  for y in 0...length
    for x in 0...length
      rotated[x][length - 1 - y] = array[y][x]
    end
  end
  rotated
end

pattern = Array.new
8.times do
  pattern << $stdin.gets.chomp.split("")
end

printf "%d\n", 90
rotate90(pattern).each do |r|
  printf "%s\n", r.join()
end

printf "%d\n", 180
rotate90(rotate90(pattern)).each do |r|
printf "%s\n", r.join()
end

printf "%d\n", 270
rotate90(rotate90(rotate90(pattern))).each do |r|
printf "%s\n", r.join()
end