#include <iostream>
#include <vector>

using namespace std;

char p[8][8];

int main()
{
    for(int i = 0; i < 8; i++) 
        for(int j = 0; j < 8; j++ )
            cin >> p[i][j];

    for(int i = 0; i < 3; ++i) {
        cout << 90 * (i + 1) << endl;
        for(int j = 0; j < 8; j++) {
            for(int k = 0; k < 8; k++) {
                char c;
                if(i == 0) {
                    c = p[j][7-k];

                } else if(i == 1) {
                    c = p[7-k][7-j];
                } else {
                    c = p[7-j][k];

                }
                cout << c;
            }
            cout << endl;
        }
    }
}