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

char M[3][8][8];
int main() {
  
  char dum;
  for(int i = 0; i < 8; i++) {
    for(int j = 0; j < 8; j++) {
      scanf("%c", &M[0][i][j]);
    }
    scanf("%c", &dum);
  }
  
  
  for(int k = 0; k < 3; k++) {
    cout << 90*(k+1) << endl;
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 8; j++) {
	cout << M[k][7-j][i];
	if(k!=2) M[k+1][i][j] = M[k][7-j][i];
      }
      cout << endl;
    }
  }
  return 0;
}