#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    string s[10];
    for(int i = 0;i < 8;i++){
        cin>>s[i];
    }

    cout<<90<<endl;
    for(int j = 0;j < 8;j++){
        for(int i = 7;i >= 0;i--){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    cout<<180<<endl;
    for(int i = 7;i >= 0;i--){
        for(int j = 7;j >= 0;j--){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    cout<<270<<endl;
    for(int j = 7;j >= 0;j--){
        for(int i = 0;i < 8;i++){
            cout<<s[i][j];
        }
        cout<<endl;
    }



    return 0;
}