#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

void Rotation(char array[][9])
{
  char tmp[9][9];
  
  memset(tmp, '\0', sizeof(tmp));
  for (int i = 0; i < 8; i++){
    for (int j = 0; j < 8; j++){
      tmp[j][i] = array[7 - i][j];
    }
  }

  for (int i = 0; i < 8; i++){
    for (int j = 0; j < 8; j++){
      array[j][i] = tmp[j][i];
    }
  }
  for (int i = 0; i < 8; i++) printf("%s\n", array[i]);
}
int main()
{
  char array[9][9];

  for (int i = 0; i < 8; i++) scanf("%s", array[i]);

  for (int i = 0; i < 3; i++){
    printf("%d\n", (i + 1) * 90);
    Rotation(array);
  }

  return (0);
}