#include <iostream>
#include <algorithm>
using namespace std;
#define N_MAX 8
#define rep(i,n) for(int i=0;i<n;i++)

char p[N_MAX][N_MAX];

void rotate(){
	rep(i,N_MAX)rep(j,i)swap(p[i][j],p[j][i]);
	rep(i,N_MAX)reverse(p[i],p[i]+N_MAX);
	rep(i,N_MAX){
		rep(j,N_MAX)cout <<p[i][j];
		cout << endl;
	}
}

int main(){
	rep(i,N_MAX)rep(j,N_MAX)cin >> p[i][j];
	cout << 90 << endl;
	rotate();
	cout << 180 << endl;
	rotate();
	cout << 270 << endl;
	rotate();
}