#include <iostream>
using namespace std;

int main() {
    char input[8][9] = {};
    for (int i = 0; i < 8; i++) {
        cin >> input[i];
    }
    for (int i = 0; i < 3; i++) {
        cout << (i + 1) * 90 << endl;
        char output[8][9] = {};
        for (int y = 0; y < 8; y++) {
            for (int x = 0; x < 8; x++) {
                output[y][x] = input[7 - x][y];
            }
        }
        for (int j = 0; j < 8; j++) {
            cout << output[j] << endl;
        }
        for (int y = 0; y < 8; y++) {
            for (int x = 0; x < 8; x++) {
                input[y][x] = output[y][x];
            }
        }
    }
}