#include <iostream>
using namespace std;

string m[8], n[8];


int main(){
    for (int i = 0; i < 8; i++)	cin >> m[i];
    
    for (int i = 1; i <= 3; i++){
	
	for (int j = 0; j < 8; j++) n[j] = m[j];
	
	for (int k = 0; k < 8; k++){
	    for (int l = 0; l < 8; l++){
		n[k][l] = m[7-l][k];
	    }
	}
	for (int k = 0; k < 8; k++){
	    for (int l = 0; l < 8; l++){
		m[k][l] = n[k][l];
	    }
	}
	
	cout << i * 90 << endl;
	for (int l = 0; l < 8; l++) cout << n[l] << endl;
    }
}