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


int main() {
  string g[8];
  for(int i = 0; i < 8; ++i) cin >> g[i];
  for(int k = 0; k < 3; ++k) {
    cout << (k+1)*90 << endl;
    string h[8];
    fill(h, h+8, string(8, ' '));
    for(int i = 0; i < 8; ++i) {
      for(int j = 0; j < 8; ++j) {
        h[i][j] = g[8-j-1][i];
      }
    }
    for(int i = 0; i < 8; ++i) {
      g[i] = h[i];
      cout << g[i] << endl;
    }
  }
}