#include <iostream>

using namespace std;

char pattern[8][8];

void inline rotate90() {
  char o[8][8];
  for (int j = 0; j < 8; j++)
    for (int i = 0; i < 8; i++)
      o[j][i] = pattern[j][i];
  for (int j = 0; j < 8; j++)
    for (int i = 0; i < 8; i++)
      pattern[j][i] = o[7-i][j];
}

void inline print_pattern() {
  for (int j = 0; j < 8; j++) {
    for (int i = 0; i < 8; i++)
      cout << pattern[j][i];
    cout << endl;
  }
}

int main() {
  for (int j = 0; j < 8; j++)
    for (int i = 0; i < 8; i++)
      cin >> pattern[j][i];
  for (int i = 1; i <= 3; i++) {
    cout << i * 90 << endl;
    rotate90();
    print_pattern();
  }
  return 0;
}